A simple and lightweight Hot Key UserControl that "enables the user to enter a combination of keystrokes to be used as a hot key". This is a drop-in ready UserControl module that wraps the Hot Key control from Windows' Common Controls Library.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Hi Bonnie,
Does this pre register (permanently register) the Hot Key, to fire up an EXE in any future session of Windows
or
Does it alert our running application, that the user clicked the hot key ?
Both the RegisterHotKey function and the WM_SETHOTKEY message require that the application should already be running in order for them to work.
If you want the ability to launch your app via a system-wide hotkey, you could create a shortcut file to your app on either the Desktop or the Start menu and in the shortcut file's Properties dialog box, type in your desired hotkey in the Shortcut key field. Windows Explorer will then register the hotkey for you every time you log on to Windows and launch your app whenever you press the hotkey.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
If you find that to be too much work, you could "cheat" by simply polling for the hotkey using a timer and then checking for the key combinations via multiple calls to GetKeyState. You won't be able to consume/discard the hotkey though.