Hello,
I am on Windows XP, and I am trying to use VB scripts to send keyboard input to an MS-DOS program. The problem is that through some weird bug in the MS-DOS program, it is only able to accept a character every 500 ms. It has no interface for automation, so I am trying to get Windows to send keys to the program for me.
Here is an example of a script that successfully sends input into internet explorer:
This technique pretty much works for any applications EXCEPT MS-DOS. How does one send input to an MS-DOS program? I've searched the web, but I have found few satisfying answers. One way is to send it input from a text file by calling a batch file That is, my script would include something likeCode:Set shell = WScript.CreateObject ("WScript.Shell") appName = "iexplore.exe" Sub giveItAKeystroke (keystrokes, name) shell.AppActivate name shell.SendKeys keystrokes End Sub WScript.Sleep 500 shell.Run appName WScript.Sleep 3000 Call giveItAKeystroke ("Hello World!", appName)
and then the batch file would haveCode:shell.Run "supporting.bat"
The problem with this is that it feeds in everything in the text file at once, and my program only accepts one character every 0.5 seconds.Code:msDosProg.exe < textFileWithInput.txt
I could have a text file for every character, but this won't work because doing msDosProg.exe < textFileWithInput.txt starts a new instance of msDosProg.exe, and I need all the input to be put into a single instance.


Reply With Quote
CodeGuru Article: 



Bookmarks