Send key sequence to ms-dos prompt

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 ;-)

 
krypto2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivanov_GCommented:
WM_KEYDOWN maybe...
0
kretzschmarCommented:
would be my guess too

WM_KEYDOWN and WM_KEYUP combination
0
geobulCommented:
SendMessage(handle, WM_CHAR, $41, 0); // sends 'A' to a command prompt window (handle)
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

geobulCommented:
A more readable version is:
SendMessage(h, WM_CHAR, Ord('A'), 0);
0
kretzschmarCommented:
good point, geo ;-)
0
geobulCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
geobulCommented:
Thanks meikl. Lots of attempts for automating third-party softwares administration/supervision tasks recently seem to have an effect ;-)
0
krypto2000Author Commented:
that's not realy hard but i have time not so much ;-)
thank you very much, the points is for you geobul !!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.