I am making a program in which I need to set multiple hotkeys that can be pressed by the user. I declared the hotkeys like this:
Dim index1 As Integer = 0
Dim hotkeycounter as integer= 0
For index0 = 0 To mainArr.GetUpperBound(0)
For index1 = 0 To mainArr.GetUpperBound(1)
If mainArr(index0, index1) = "" Then
MsgBox("exited the unregisterhotkey for loop")
GoTo line1
End If
UnregisterHotKey(Me.Handle, hotkeycounter)
hotkeycounter = hotkeycounter + 1
Next
Next
line1:
hotkeycounter = 0
For index0 = 0 To mainArr.GetUpperBound(0)
For index1 = 0 To index1 = 1
If mainArr(index0, index1) = "" Then
MsgBox("exited the registerhotkey for loop")
GoTo line2
End If
RegisterHotKey(Me.Handle, hotkeycounter, &H1, index0)
hotkeycounter = hotkeycounter + 1
MsgBox("A hotkey has been registered")
MsgBox(($"{mainArr(index0, index1)} "))
Next
Next
line2:
So basically the command values for the hotkey are read out of an array. My issue is that I am unable to detect which array is pressed (defined by 'hotkeycounter'). My code to try to detect which hotkey is pressed is:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim specialcharacter As String
If m.Msg = WM_HOTKEY Then
If commandID = 0 Then
MsgBox("You pressed the first key combination")
ElseIf commandID = 1 Then
MsgBox("You pressed the second key combination")
ElseIf commandID = 2 Then
MsgBox("you pressed the third key combination")
End If
End If
MyBase.WndProc(m)
End Sub