Link to home
Start Free TrialLog in
Avatar of AGuillien
AGuillien

asked on

Simulating keystrokes to a MS-DOS window

Hello,
I would like to send keys to an MS-DOS window, truely simulating the action of a user on the window.
I've tried with Keybd_event but it doesn't work (it works with standard windows).

Thanks,

Alexandre Guillien
Avatar of Epsylon
Epsylon

I think you need to send messages to the window handle:

SendMessage(hwnd, WM_KEYDOWN, nVirtKey, lKeyData);

and

SendMessage(hwnd, WM_KEYUP, nVirtKey, lKeyData);
Hi Alexandre

This might not be what you want but take a look at:

http://ckb.netalive.org/cgi-bin/ckb.pl?mode=show_snippet&cat=delphi_system_32bit&snippetnr=52

it's supposed to take keystrokes from a supplied text file.

Cheers - Walter McKie
Using Keybd_event will work on a DOS window if you use AttachThreadInput as well. The problem is with some MS-DOS apps that sending Windows messages won't work.

I think the main reason is the vast number of "ill-behaved" MS-DOS apps made in the 80's. A lot of programmers (and programming tools) used BIOS calls to read keystrokes to get complete control over the keyboard. I don't think you can synthesize keystokes for this kind of apps using Windows calls - you'll have to generate BIOS "messages". This shouldn't be too much trouble provided you can find the documentation...

If all else fails - follow this tip.

runebj
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial