Originally Posted by
Ninja™
Nice dude. I made one with VB but i cant get the hot keys to work for mine.Should i count on you for help?
I don't take credit for this method.
Under Public Class Form1:
Code:
Public Const WM_HOTKEY As Integer = &H312
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Make a button. Then add this:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call RegisterHotKey(Me.Handle, 9, 0, Keys.Q)
End Sub
Also add:
Code:
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Call UnregisterHotKey(Me.Handle, 9)
End Sub
Lastly, add:
Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
'What ever you want the hotkey to do.
End If
MyBase.WndProc(m)
End Sub
This is better than GetASyncKeyState. Also, this will assign the key 'Q' the hotkey.