473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Send Ctrl+C in testcase.

zlf
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
Jan 12 '08 #1
3 4003
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"zlf" <zl***@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP02.phx.gbl...
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

Jan 14 '08 #2

"zlf" <zl***@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP02.phx.gbl...
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/lib...55(VS.85).aspx
Jan 16 '08 #3
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
Jan 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
6
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the...
3
by: Str Noetika | last post by:
Hi, How can I send ctrl keys (like ctrl A, ctrl C) from a VB application to another existing application (like word, excel...) ? I tried to send postmessages like...
4
by: F.C. | last post by:
Hi code gurus ! I'm creating a front end for a DOS application using VB .Net. I launch this DOS app using System.Diagnostics.Process : myProcess.StartInfo.FileName = "myapp.exe"...
3
by: William Stacey [MVP] | last post by:
How do you send Ctrl-C to a standard input stream? Just sending 03 does not work. -- William Stacey
2
by: abhay | last post by:
hi,i m interfacing gsm modem to my microcontroller.i need to send sms through it. i am using AT commands for that.the command to send sms (AT+ CMGS) terminates with ctrl-Z.now in my program i hav...
1
by: Gustavo Narea | last post by:
Hello, everyone. Why do unitest.TestCase grand-grandchildren not work? I've created a unittest.TestCase descendant, which contains the setUp() and tearDown() for testing some components of a...
0
by: Gabriel Genellina | last post by:
En Tue, 19 Aug 2008 18:35:57 -0300, Gustavo Narea <me@gustavonarea.net> escribi�: Do you have any reason for such meta-testing? If you want to ensure that all derived Test classes correctly...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.