Reputation: 43
When I press Q, I have code that makes my mouse move away and click, therefore making the form inactive, and clicking whatever was there.
Now, when I press Q again, it doesn't work, because the form is inactive. How do I make the KeyDown events still fire when the form is not active?
Upvotes: 2
Views: 1270
Reputation: 4463
If your application doesn't have focus then it can not trigger the KeyDown
events.
In those cases you have two options. Assuming you only want to monitor 1-2 keys then you can register a hotkey using the RegisterHotKey function as seen in this example.
If you want to monitor more than that then it would be more sensible to use a low level keyboard hook instead.
Upvotes: 3