Solved

Simulating keystrokes to a MS-DOS window

Posted on 2000-03-21
5
192 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

730 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