tags:

views:

61

answers:

1

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
Looks like it doesn't work. I write 3 to input stream but without any success.
Idsa
how did u write 3 to stream? "3" or `char.ConvertFromUtf32(3)`. vote up if this works :)
Ankit Jain
I just recorded byte 3. I also tried char.ConvertFromUtf32(3) - it doesn't work also.
Idsa