by Anonymous (267 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 13th January 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Create a hotkey for your application
API Declarations
Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_SETHOTKEY = &H32
Public Const WM_SHOWWINDOW = &H18
Public Const HK_SHIFTA = &H141 'Shift + A
Public Const HK_SHIFTB = &H142 'Shift * B
Public Const HK_CONTROLA = &H241 'Control + A
Public Const HK_ALTZ = &H45A
Dim lngReturn As Long
'minimize window
Me.WindowState = vbMinimized
'select the hotkey for your app, ALT-Z in this case
lngReturn = SendMessage(Me.hwnd, WM_SETHOTKEY, HK_ALTZ, 0)
'Check if succesfull
If lngReturn <> 1 Then
MsgBox "Select another hotkey"
End If
'Tell windows what to do when hotkey is selected
lngReturn = DefWindowProc(Me.hwnd, WM_SHOWWINDOW, 0, 0)