Hello! I wonder how im gonna write to make a hotkey! with CTRL ALT F9 buttons!

I dont know how to write the code, also if im gonna write VbKeyCTRL+ALT+F9 or how to do :S

Here's anyway the whole code..


In the forms:

VbKey Code:
  1. Private Sub Form_Load()
  2.     Dim ret As Long
  3.     bCancel = False
  4.     'register the hotkeys
  5.     ret = RegisterHotKey(Me.hWnd, &HBFF0&, 0, vbKeyF8)
  6.     ret = RegisterHotKey(Me.hWnd, &HBFFF&, 0, vbKeyF9)
  7.     'show the form and
  8.     Show
  9.     'process the Hotkey messages
  10.     ProcessMessages
  11. End Sub
  12.  
  13. Private Sub Form_Unload(Cancel As Integer)
  14.     'disable the hotkeys YOU MUST DO THIS BEFORE PRESSING STOP!
  15.     bCancel = True
  16.     Call UnregisterHotKey(Me.hWnd, &HBFF0&)
  17.     Call UnregisterHotKey(Me.hWnd, &HBFFF&)
  18. End Sub

And in the module:

VbKey Code:
  1. Option Explicit
  2.  
  3. Private Const MOD_ALT = &H1
  4. Private Const MOD_CONTROL = &H2
  5. Private Const MOD_SHIFT = &H4
  6. Private Const PM_REMOVE = &H1
  7. Private Const WM_HOTKEY = &H312
  8. Private Type POINTAPI
  9.     x As Long
  10.     y As Long
  11. End Type
  12. Private Type Msg
  13.     hWnd As Long
  14.     Message As Long
  15.     wParam As Long
  16.     lParam As Long
  17.     time As Long
  18.     pt As POINTAPI
  19. End Type
  20. Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
  21. Public Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
  22. Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
  23. Private Declare Function WaitMessage Lib "user32" () As Long
  24. Public bCancel As Boolean
  25. Public Sub ProcessMessages()
  26.     Dim Message As Msg
  27.     'loop until bCancel is set to True
  28.     Do While Not bCancel
  29.         'wait for a message
  30.         WaitMessage
  31.         'check if it's a HOTKEY-message
  32.         If PeekMessage(Message, Form1.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
  33.             If Message.wParam = &HBFF0& Then
  34.                 MsgBox "WAAH!"
  35.         'let the operating system process other events
  36.         DoEvents
  37.     Loop
  38. End Sub