tags:

views:

67

answers:

1

I'm using delphi to add an graphical interface to a console application. The problem is when the console application asks for input. I would normally type in my input and press enter to make it accept my string, but I don't know how to do this.

I'm using this library as a "wrapper" over the console application, it uses pipes for the input and output streams. http://koders.com/delphi/fidDB05C6361540F62D532FC7C960D4111CE3AAEDB3.aspx?s=proxy

I've tried things like WriteToConsoleApp(#04); to send an EOT, which is Control-D. This would normally work but in this case it doesn't do anything. I've also tried WriteToConsoleApp(#13); WriteToConsoleApp(#13#10);, but none of these solutions work.

If you have any advice I would be grateful.

A: 

You can use SendMessage or PostMessage function to send string/key to console application. For example;

SendMessage(WindowHandle, WM_CHAR, Ord('A'), 0);//sends 'A' to the window

or

PostMessage(WindowHandle, WM_KEYDOWN, VK_RETURN, 0);//sends Return to the window
SimaWB
The console program was created with the `CREATE_NO_WINDOW` flag. There's no place to send those messages.
Rob Kennedy
Maybe I can change it so that the input stream is on a hidden window.
Nowayz