Using VB to send keyboard input to an MS-DOS program
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 like
Set shell = WScript.CreateObject ("WScript.Shell")
appName = "iexplore.exe"
Sub giveItAKeystroke (keystrokes, name)
Call giveItAKeystroke ("Hello World!", appName)
and then the batch file would have
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.
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.
Using API's you might be able to do it. Check out this article that I reviewed. I've used it to send keys to a Java program. I had a 50ms timer between keys. Oddly enough, I needed a VB.Tab to click the submit button.
David CodeGuru Article: Bound Controls are Evil-VB6
2006 Dell CSP
2006, 2007 & 2008 MVP Visual Basic If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
By Dude in forum VB Classic
Last Post: 10-19-2006, 11:17 AM
By anonyentry in forum VB Classic
Last Post: 05-27-2006, 03:06 AM
By J. Long in forum VB Classic
Last Post: 03-20-2002, 09:12 AM
By Gordon Reichhardt in forum VB Classic
Last Post: 01-08-2002, 11:06 AM
Last Post: 10-03-2001, 10:14 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL