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!

Sending keystrokes to DOS program

Status
Not open for further replies.

philrosenberg

Technical User
Dec 3, 2003
15
GB
I'm writing a program that needs to run a number of DOS programs and send keyboard input to them.
I'm currently using CreateProcess() to open the applications and keybd_event() to generate the input. However this seems a very inelegant way to do this, especially as it seems that the application I want to receive the keystrokes has to have the focus. Is there any better way to send the keyboard input, perhaps generating a WM_KEYDOWN message using PostThreadMessage()?

Thanks for any help

Phil
 
You could try this
Code:
FILE *fp = _popen( "mydosprog.exe", "w" );
fprintf( fp, "A_Command\n" );
_pclose( fp );

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top