Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to catch keyboard - on a console application?
How to catch keyboard - on a console application? [message #6941] Tue, 05 December 2006 15:20 Go to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi all!

Last time I asked how to get keyboard input via Ctrl. The solution was easy - only overwrite the Key-Method of the Ctrl.

But now I have to develop a console application (windows service) without any Ctrl. Is there also a possibility to detect a key?

I found some code in this forum (kbhit() and getch()), but that does not work (as I read still after testing). Would be happy, if you have another solution.

In short form: I have to break a while loop, when user press "x" (for example).


Thank you,

WebChaot
Re: How to catch keyboard - on a console application? [message #6947 is a reply to message #6941] Tue, 05 December 2006 17:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This is highly specific problem IMHO.

AFAIK, windows services that expect user input simply add some gui elements (which reduces it to the former solution).

Mirek
Re: How to catch keyboard - on a console application? [message #6972 is a reply to message #6947] Wed, 06 December 2006 09:34 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi Mirek!

>>> AFAIK, windows services that expect user input simply add some gui elements (which reduces it to the former solution).

Not really. I want to implement a command line argument "-d" to start the "service" as a stand alone program (for testing and for manual operation). And because its a console application I have no window, but want to break the loop by pressing a key.

Usually the loop runs until the service gets the stop command. For testing mode I have to break the loop otherwise.

Is there no easy solution to do that? If not, I will terminate program in task manager every time, because CTRL-C doesnt work too Smile


Thanks,

WebChaot.
Re: How to catch keyboard - on a console application? [message #6978 is a reply to message #6972] Wed, 06 December 2006 12:12 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ah, but that is completely different thing Smile

Look into Console API documentation:

http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dllproc/base/allocconsole.asp

Mirek
Previous Topic: Stream::Putf
Next Topic: Bug in "One" documentation?
Goto Forum:
  


Current Time: Tue May 07 08:23:36 CEST 2024

Total time taken to generate the page: 0.02408 seconds