Well, i found some things about RegisterHotkey API, but I still have an issue to toggle off the hotkey...
So, where do I place this flag "CheckBox1.Checked = Not CheckBox1.Checked" to toggle on/off the checkbox?Code:Public Class Form1 #Region "REGISTER HOTKEYS" Public Const WM_HOTKEY As Integer = &H312 <DllImport("User32.dll")> _ Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, _ ByVal id As Integer, ByVal fsModifiers As Integer, _ ByVal vk As Integer) As Integer End Function <DllImport("User32.dll")> _ Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, _ ByVal id As Integer) As Integer End Function #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RegisterHotKey(Me.Handle, 1, 0, Keys.NumPad8) 'REGISTER NUMPAD8 End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then Dim id As IntPtr = m.WParam Select Case (id.ToString) Case "1" RegisterHotKey(Me.Handle, 1, 0, Keys.NumPad8) checkbox1.checked=true End Select End If MyBase.WndProc(m) End Sub End Class




Reply With Quote
