Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send keys not send the correct character? 2

Status
Not open for further replies.

bct10

Technical User
May 3, 2004
37
US
I am use this script
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("Test.txt")
While oFile.AtEndOfStream <> True
strLine = oFile.ReadLine
If InStr(strLine, "REV") > 0 Then
arrParts = Split(strLine, "|")

End If
Wend

rem WScript.Echo arrParts(7)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate ("notepad")

WshShell.sendkeys arrParts(6)

WshShell.sendkeys ".txt"

the output I am getting is REVNPW>TXT

I would like to why i get a > when it should be a .
if rem out WshShell.sendkeys arrParts(6)
I get .txt thanks for an help you can give me on what i am doing wrong
 
Hello again,

I just use your file and code to test. The result is as expected and normal.

Test the ascii and unicode possibility. The instr() is default to ascii. What if the source file is unicode, which is a rule for winnt/2k up? Test successively these lines with parameters:
[a] Your case at present
Set oFile = oFSO.OpenTextFile("Test.txt",,0)
unicode
Set oFile = oFSO.OpenTextFile("Test.txt",,-1)
[c] system default
Set oFile = oFSO.OpenTextFile("Test.txt",,-2)

regards - tsuji
 
For a sub:
Code:
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("Test.txt")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Exec("notepad.exe")
WScript.Sleep(3000)
While oFile.AtEndOfStream <> True
    strLine = oFile.ReadLine
    If InStr(strLine, "REV") > 0 Then
        arrParts = Split(strLine, "|")
        WScript.Echo "Found"
        SendMyKeys(arrParts(6))
    End If
Wend
oFile.close

Sub SendMyKeys(strFoundString)
    WshShell.AppActivate ("notepad")
    WshShell.sendkeys arrParts(6) 
    WshShell.sendkeys strFoundString
End Sub

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
bct10,

Thanks for the votes. But, what really was happening?

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top