Grez
Grez

Reputation: 59

Record keys for console app without focus

I am doing an console application that is working with other apps. While the code works with the other apps the console does not have the focus so the console does not record the keyboard ... I would like to be able to set a "watcher" in background on the console app to pause (with space) and stop (with escape) while the code does what it have to do.

This does not work for console apps because it is not a Window form so the override of WndProc does not find any method to override

Upvotes: 0

Views: 222

Answers (1)

Calum
Calum

Reputation: 11

You can use a keyboard hook, check this question for information.

If you don't like the idea of that. Use unity, i know it sounds stupid but Unity has a keyhook handler.

eg:

Input.GetKeyDown("space");

Its very useful.

Upvotes: 1

Related Questions