Solved

Simulating keystrokes to a MS-DOS window

Posted on 2000-03-21
5
189 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 304
Using idhttp to login to instagram 2 90
Convert a string into a TDateTime 5 61
Base1 Encode/Decode 3 77
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

810 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