Solved

Simulating keystrokes to a MS-DOS window

Posted on 2000-03-21
5
185 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
Comment Utility
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
Comment Utility
0
 
LVL 1

Expert Comment

by:wmckie
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now