I am having two problems:
Problem 1: I am unable to register a series of key combinations, such as Ctrl + Shift + E + K, I can only register E or K...
Problem 2: when I put Keys.Control, or Keys.Shift in the second last parameter of RegisterHotKey (which is the fsModifiers parameter) the hotkey doesn't work... even if I put in the last parameter as Keys.Control where normally Keys.E would go, it doesn't launch when I press control...
Does anyone know why?
The code I am using:
vb.net Code:
Public Class Form1 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 Public Const WM_HOTKEY As Integer = &H312 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then ' Pressed the hotkey Debug.WriteLine(m.Msg.ToString & ":" & m.WParam.ToString & ":" & m.LParam.ToString) End If MyBase.WndProc(m) End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles e.FormClosing Call UnregisterHotKey(Me.Handle.toint32, 0) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call RegisterHotKey(Me.Handle.toint32, 0, 0, 27) End Sub End Class
Thanks




Reply With Quote