C# console get key stroke
Question
Is there anyway for a C# console application to capture keystroke, including those that are pressed outside of the program, similar to a key logger? The one I found and tried is Console.ReadKey() but it can only read the keystroke sent to the console.
Solution
You need to use a low level keyboard hook. Here is an example using windows forms, but you can easily apply the same concept to a console application:
http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
Hope it helps!
OTHER TIPS
You'd have to handle global keyboard events. Have a look at A Simple C# Global Low Level Keyboard Hook
You will need to use the Windows API, I'd check GetAsyncKeyState.
yes...you'll need to look at system keyboard hooks...I think this post has what you need: