dcsimg
December 9, 2016
Hot Topics:

Create a Hotkey for your Application

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

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



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel