Results 1 to 3 of 3

Thread: [RESOLVED] Hotkeys just a tiny bit of help needed here

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Resolved [RESOLVED] Hotkeys just a tiny bit of help needed here

    ok i got my hotkey working
    VB.NET Code:
    1. Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    2.     Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
    3.  
    4.     Private Const WM_HOTKEY As Integer = &H312
    5.  
    6.     Private Const MOD_ALT As Integer = &H1
    7.     Private Const MOD_CONTROL As Integer = &H2
    8.     Private Const MOD_SHIFT As Integer = &H4
    9.  
    10.     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    11.         UnregisterHotKey(Me.Handle, 0)
    12.     End Sub
    13.  
    14.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    15.         RegisterHotKey(Me.Handle, 0, 0, Asc("C"))
    16.     End Sub
    17.  
    18.     Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    19.  
    20.         If m.Msg = WM_HOTKEY Then
    21.            'DO WHATEVER HERE
    22.         MyBase.WndProc(m)
    23.  
    24.     End Sub
    Ok there i have one that is when u press C, i also want another for when you press R but i dont know how to have two at the same time, some help please. Cheers.
    EDIT: I need to know the IF statement for it as well please.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Hotkeys just a tiny bit of help needed here

    vb Code:
    1. Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    2. Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
    3. Private Const WM_HOTKEY As Integer = &H312
    4. Private Const MOD_ALT As Integer = &H1
    5. Private Const MOD_CONTROL As Integer = &H2
    6. Private Const MOD_SHIFT As Integer = &H4
    7. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    8.     UnregisterHotKey(Me.Handle, 0)
    9.     UnregisterHotKey(Me.Handle, 1)
    10. End Sub
    11. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    12.     RegisterHotKey(Me.Handle, 0, 0, Asc("C"))
    13.     RegisterHotKey(Me.Handle, 1, 0, Asc("R"))
    14. End Sub
    15. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    16. If m.Msg = WM_HOTKEY Then
    17. 'DO WHATEVER HERE
    18.     if m.WParam = 0 then
    19.       'C pressed
    20.   elseif m.WParam = 1 then
    21.       'R pressed
    22.   end if
    23. MyBase.WndProc(m)
    24. End Sub

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width