I Have a GUI app that reads a console application that shows output and waits for F4 to exit, I've managed to launch the process with:
p.StartInfo.FileName = "consoleapp.exe";
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.RedirectStandardInput = false;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(ConsoleOutputHandler);
p.Start();
p.BeginOutputReadLine();
And I can send F4 using:
PostMessage(p.MainWindowHandle, (uint)WM_KEYUP, (IntPtr) Keys.F4, (IntPtr) 0x3E0001 );
Everything works fine until I redirect StandardOutput with:
p.StartInfo.RedirectStandardOutput = true;
That way PostMessage still send the event (checked by Spy++), but the console app doesn't recognize it.
Changing "RedirectStandardInput" didn't make any progress.
Any thoughts?