THANK YOU SO MUCH! I been searching how to do that for a long time 3>
@mrhem53714 жыл бұрын
Glad it helped!
@gerryRD193 жыл бұрын
Is there a way to register multiple keys? For example I want to register a hotkey that handles Win+V
@mrhem53713 жыл бұрын
We can use the modifier parameter to couple the key with an ALT, CRLT or WIN. In the documentation, it says the WINDOWS keys are reserved for use by the operating system, so I'd avoid using that with RegisterHotKey(). If you still want to use the WIN key or do more interesting stuff I recommend looking into www.autohotkey.com/ AUTOHOTKEY. Here would be the modifications required to couple with an ALT key. 'change the id to integer instead of keys Public Declare Auto Function RegisterHotKey Lib "User32.dll" (ByVal x As IntPtr, ByVal id As Integer, modifier As UInteger, keycode As Keys) As Long Public Const WM_HOTKEY = &H312 Public Const MOD_ALT = &H1 'add the MOD_ALT hex Protected Overrides Sub WndProc(ByRef m As Message) MyBase.WndProc(m) If (m.Msg = WM_HOTKEY) Then Dim id = m.WParam.ToInt32 If (id = 1) Then 'check for the id number MsgBox("ALT A") End If End If End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load RegisterHotKey(Me.Handle, 1, MOD_ALT, Keys.A) 'id 1 is registered with ALT A End Sub
@TheDailyRant3 жыл бұрын
@@mrhem5371 Loved the video great tuition and very helpful. I am using VS 2019 on windows 10. I had to update a line of your code to make it work on my system... from RegisterHotKey(Me.Handle, 1, MOD_ALT, Keys.A) 'id 1 is registered with ALT A to RegisterHotKey(Me.Handle, 1, CUInt(MOD_ALT), Keys.A) 'id 1 is registered with ALT A It works perfectly now. Thanks