Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Send key sequence to ms-dos prompt

Posted on 2004-10-28
8
Medium Priority
?
401 Views
Last Modified: 2010-04-05
Hello,

I want to send a key-sequence, "abcdef" for example, to the dos command prompt with the sendMessage function.
I can get the handle, no problem, but after i didn't know what is the WM_COMMAND to send text.
I've tried with WM_SETTEXT but that change the caption of the console...

That's all ;-)

 
0
Comment
Question by:krypto2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12432902
WM_KEYDOWN maybe...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12433032
would be my guess too

WM_KEYDOWN and WM_KEYUP combination
0
 
LVL 17

Expert Comment

by:geobul
ID: 12433147
SendMessage(handle, WM_CHAR, $41, 0); // sends 'A' to a command prompt window (handle)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:geobul
ID: 12433171
A more readable version is:
SendMessage(h, WM_CHAR, Ord('A'), 0);
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12433203
good point, geo ;-)
0
 
LVL 17

Accepted Solution

by:
geobul earned 500 total points
ID: 12433224
And a routine:

procedure SendToDosWindow(h: HWND; what: string);
var
  i: integer;
begin
  for i := 1 to Length(what) do
    SendMessage(h, WM_CHAR, Ord(what[i]), 0);
end;

// usage
var
  h: HWND;
begin
  h := FindWindow(nil, 'Command Prompt');
  if IsWindow(h) then begin
    SendToDosWindow(h, 'abcdef');
  end else ShowMessage('Window not found');
end;

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 12433283
Thanks meikl. Lots of attempts for automating third-party softwares administration/supervision tasks recently seem to have an effect ;-)
0
 

Author Comment

by:krypto2000
ID: 12434442
that's not realy hard but i have time not so much ;-)
thank you very much, the points is for you geobul !!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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