This code lets you use hotkeys from your program. Even if your app is not in focus the hotkey will work. This one is CTRL + A
Also to change the Keys you will probably need the Virtual Key codes
They Are Here
VB.NET Code:
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer Private Const WM_HOTKEY As Integer = &H312 Private Const MOD_ALT As Integer = &H1 Private Const MOD_CONTROL As Integer = &H2 Private Const MOD_SHIFT As Integer = &H4 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing UnregisterHotKey(Me.Handle, 0) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RegisterHotKey(Me.Handle, 0, MOD_CONTROL, Asc("A")) End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then If m.WParam = 0 Then 'CODE HERE End if End If MyBase.WndProc(m) End Sub


)
Reply With Quote

