Hi I'm developing a C# WM 6.5 console application. It is running in the background while another application has focus. I need to be able to capture when the user presses the ESC key however I do not want to interfere with the operation of the main application. I have no idea how to do this. Any suggestions?
Asked
Active
Viewed 318 times
0
-
Sounds like a keylogger feature. You can check keylogging documents. – Ignacio Soler Garcia Jul 10 '13 at 13:45
-
Sounds like there is no native/easy method, but with some Help of interop (say, "`PInvoke`") and this reply (C++ code!) combined with a learning process, it might point you into the right direction. http://stackoverflow.com/a/1047829/265165 – thmshd Jul 10 '13 at 13:52
-
do you know how to get and dispatch messages? – No Idea For Name Jul 10 '13 at 13:53
-
Turns out I can just use the following with WM 6.5: [System.Runtime.InteropServices.DllImport("coredll.dll")] public static extern short GetAsyncKeyState(int keyCode); if (GetAsyncKeyState(27) != 0) { //do something here cause the ESC key was pressed } – user2568780 Jul 10 '13 at 17:10
1 Answers
0
Can you please post your exact method
[System.Runtime.InteropServices.DllImport("coredll.dll")]
public static extern short GetAsyncKeyState(int keyCode);
if (GetAsyncKeyState(27) != 0) { //do something here cause the ESC key was pressed }

Wahab Hussain
- 1
- 1