Skip to content

Instantly share code, notes, and snippets.

View ocdtrekkie's full-sized avatar
🤷‍♂️
Writing whatever comes to mind

Jacob Weisz ocdtrekkie

🤷‍♂️
Writing whatever comes to mind
View GitHub Profile

Authored in 2010

When you want to make your application do things by the user pressing a hotkey / key combination, even when your application does not have focus, you will need a so called global hotkey. A global hotkey is a form of "keyboard hook" which is a low level way of monitoring the computer for a certain key combination, aka hotkey. Below is a simple class, which let's you register a hotkey and define what code should execute, once the hotkey is pressed.

    Public Class Hotkey

#Region "Declarations - WinAPI, Hotkey constant and Modifier Enum"