Solved

Simulating keystrokes to a MS-DOS window

Posted on 2000-03-21
5
191 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:AGuillien
  • 3
5 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2640143
I think you need to send messages to the window handle:

SendMessage(hwnd, WM_KEYDOWN, nVirtKey, lKeyData);

and

SendMessage(hwnd, WM_KEYUP, nVirtKey, lKeyData);
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2640152
0
 
LVL 1

Expert Comment

by:wmckie
ID: 2640154
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
0
 
LVL 1

Expert Comment

by:runebj
ID: 2643464
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
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 200 total points
ID: 2654915
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question