System Wide KeyBoard Hooks
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Thanks, i saw it just now
And worked a little with it, i added items to ListMod1 and ListMod2:


Code: Select all
And it works perfect None
Alt
Ctrl
Shift

mandai wrote:Here is an example where you can register and unregister hotkeys by using form controls:#mandai I think this is what i need, but i get errors from the DLLimport and Im confused on what all those listboxes do, please if u can explain or give me a source codeCode: Select allWhere listHotkeys, listMod1, listMod2 and listKey are ListBox controls.Dim keyNames As String() Dim keyValues As Array Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load keyNames = [Enum].GetNames(GetType(Keys)) For i As Integer = 0 To keyNames.Length - 1 listKey.Items.Add(keyNames(i)) Next If listKey.Items.Count > 0 Then listKey.SelectedIndex = 0 keyValues = [Enum].GetValues(GetType(Keys)) End Sub <DllImport("user32.dll")> Shared Function RegisterHotKey(ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As UInteger, ByVal vk As UInteger) As Boolean End Function Dim lastID As Integer = 0 Dim IDs As List(Of Integer) = New List(Of Integer) Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click Dim modifiers As UInteger = 0 Select Case listMod1.SelectedIndex Case 1 modifiers += 1 'alt Case 2 modifiers += 2 'ctrl Case 3 modifiers += 4 'shift Case 4 modifiers += 8 'win End Select Select Case listMod2.SelectedIndex Case 1 modifiers += 1 Case 2 modifiers += 2 Case 3 modifiers += 4 Case 4 modifiers += 8 End Select listHotkeys.Items.Add("ID: " & lastID & ", Modifiers: " & modifiers & ", " & keyNames(listKey.SelectedIndex)) IDs.Add(lastID) RegisterHotKey(Me.Handle, lastID, modifiers, keyValues(listKey.SelectedIndex)) lastID += 1 End Sub <DllImport("user32.dll")> Shared Function UnregisterHotKey(ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean End Function Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click If listHotkeys.SelectedIndex > -1 Then MsgBox("Unregistering hotkey " & listHotkeys.SelectedItem) UnregisterHotKey(Me.Handle, IDs(listHotkeys.SelectedIndex)) IDs.RemoveAt(listHotkeys.SelectedIndex) listHotkeys.Items.RemoveAt(listHotkeys.SelectedIndex) End If End Sub Const WM_HOTKEY As Integer = &H312 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then MsgBox("hotkey with ID " & m.WParam.ToInt32() & " pressed") End If MyBase.WndProc(m) End Sub
also where do I change it to be SHIFT F1 and SHIFT F2 ?
ty
The listboxes are used to set the keys that it looks for.
For example if you need to check for Shift+F1 then ListMod1 would be at index 3 and listKey would match the index for F1. After btnSet is clicked it will listen, then when the hotkey is pressed it will run the code in WndProc.
This is all the source code that you should need, though there is a Microsoft article about this function here.
What error does the DLLImport give?
For example if you need to check for Shift+F1 then ListMod1 would be at index 3 and listKey would match the index for F1. After btnSet is clicked it will listen, then when the hotkey is pressed it will run the code in WndProc.
This is all the source code that you should need, though there is a Microsoft article about this function here.
What error does the DLLImport give?
mandai wrote:The listboxes are used to set the keys that it looks for.sorry for the late reply, i seem to be very confused, thats fine i wont use this as nobody seem to know how to explain it well, thanks mandai for this btw
For example if you need to check for Shift+F1 then ListMod1 would be at index 3 and listKey would match the index for F1. After btnSet is clicked it will listen, then when the hotkey is pressed it will run the code in WndProc.
This is all the source code that you should need, though there is a Microsoft article about this function here.
What error does the DLLImport give?

Copyright Information
Copyright © Codenstuff.com 2020 - 2023