Hello
I'm writing testcase for my console application. One testcase requires to
test press Ctrl+C while the application is running.
How to send Ctrl+C while running application through
System.Diagnostics.Process?
I know I can simulate input through p.StandardInput.WriteLine, but I do not
know what exactly input string represents "Ctrl+C".
Thanks
Nicholas Paldino [.NET/C# MVP] - 14 Jan 2008 17:05 GMT
zlf,
If you can make the console app the active application, you could use
the SendKeys class to send a key sequence to the app.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hello
> I'm writing testcase for my console application. One testcase requires to
[quoted text clipped - 5 lines]
>
> Thanks
Ben Voigt [C++ MVP] - 16 Jan 2008 15:31 GMT
> Hello
> I'm writing testcase for my console application. One testcase requires to
> test press Ctrl+C while the application is running.
> How to send Ctrl+C while running application through
> System.Diagnostics.Process?
Since console applications in Windows receive that as a console control
signal through SetConsoleCtrlHandler, you'd use the matching function
GenerateConsoleCtrlEvent.
Looks like you'll need to use a process group and know the PID of the
process.
Then p/invoke to GenerateControlCtrlEvent:
http://msdn2.microsoft.com/en-us/library/ms683155(VS.85).aspx
christery@gmail.com - 17 Jan 2008 19:20 GMT
Could be silly, but not wanting the os to know then pass it ascii char
3, wont break the exec...
like Ctrl+Break that sets of OS interrupts, as do Ctrl+C, creates
events
//CY