I have to send to send Ctrl+C to console process created from my C# application. I have found a lot of similar threads but haven't found a solutaion (tried CreateProcess, GenerateConsoleCtrlEvent, etc.). Is there any working example?
A:
The key CRTL + C
is ASCII 3 (in decimal)
myProcess.StartInfo.FileName = "Sort.exe";
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
myStreamWriter.WriteLine(inputText);
Ref: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx
Ankit Jain
2010-07-26 05:12:55
Looks like it doesn't work. I write 3 to input stream but without any success.
Idsa
2010-07-26 06:08:41
how did u write 3 to stream? "3" or `char.ConvertFromUtf32(3)`. vote up if this works :)
Ankit Jain
2010-07-26 06:22:51
I just recorded byte 3. I also tried char.ConvertFromUtf32(3) - it doesn't work also.
Idsa
2010-07-26 06:32:58