Create a Hotkey for your Application
Add a new form and draw on a command button (cmdEnd). Copy the following code into the form:
Option Explicit Private Declare Function SendMessage Lib_ "user32" _ Alias "SendMessageA"_ (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam_ As Long, lParam As Long) As Long Private Const WM_SETHOTKEY = &H32 '// Shift + A Private Const HK_SHIFTA = &H141 '// Shift * B Private Const HK_SHIFTB = &H142 '// Control + A Private Const HK_CONTROLA = &H241 Private Const HK_ALTZ = &H45A Private Sub cmdEnd_Click() Unload Me End Sub Private Sub Form_Load() '// Start subclassing the form Subclass Me.hwnd '// Assign our hotkey SendMessage Me.hwnd, WM_SETHOTKEY,_ HK_ALTZ, 0 End Sub Private Sub Form_Unload(Cancel As Integer) '// End subclassing unless you want '// abnormal effects on the system UnSubclass Me.hwnd End Sub
Page 2 of 3
This article was originally published on November 20, 2002