I’m feeling frustrated. I have spent hours looking for a good piece of code to capture the keypress events in any windows no matter if my application is focused or not. I need to create an application to work in the background to capture the F5 key. Does anyone have any code?
Share
I know this is all C# and OP asked about VB.Net, but the concepts are the same…
I wrote a simple utility that handled global key presses using this project. Download the library, and add a reference to it in your project, and import the
Gma.UserActivityMonitornamespaceIn your form load event, add the handlers.
In these methods, I’m looking for either control key to be pressed.
With the way this is written, the key press will still be available to other apps to process. If you want to “capture” the key and halt its processing by other apps, set the Handled property to true in your event handler.
EDIT: Conversion of above code to VB.Net
To add handlers in VB.Net, you use
AddHandlerandAddressOf.The functions
KeyDownandKeyUpwould look like this.