I am trying to find a way to set the hotkey using the following loop:
Dim hotKEY(1) as string
Dim tmpKey as new Keys
Dim chosenLetter As Char = "B"
hotKEY(0) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
hotKEY(1) = "CTRL"
For Each Letter In hotKEY(0).ToCharArray()
If chosenLetter = Letter Then
tmpKey = Asc(Letter)
Exit For
End If
Next
If hotKEY(1) = "SHIFT" Then 'shift
RegisterHotKey(Me.Handle, 100, MOD_SHIFT, tmpKey)
ElseIf hotKEY(1) = "CTRL" Then 'control
RegisterHotKey(Me.Handle, 100, MOD_CONTROL, tmpKey)
ElseIf hotKEY(1) = "ALT" Then 'alt
RegisterHotKey(Me.Handle, 100, MOD_ALT, tmpKey)
ElseIf hotKEY(1) = "WIN" Then 'windows key
RegisterHotKey(Me.Handle, 100, MOD_WIN, tmpKey)
End If
In the above code, tmpKey would be the chosen key letter (A-Z/0-9). However, I am unable to do this since it supposed to be Keys.A, Keys.B, Keys.C, etc etc.
Is this possible to do with my current code above?
Well i got it just now! :o)
Dim hotKEY(1) as string
Dim tmpKey as new Keys
Dim chosenLetter As Char = "B"
hotKEY(0) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
hotKEY(1) = "CTRL"
For Each Letter In hotKEY(0).ToCharArray()
If chosenLetter = Letter Then
tmpKey = Asc(Letter)
Exit For
End If
Next
If hotKEY(1) = "SHIFT" Then 'shift
RegisterHotKey(Me.Handle, 100, MOD_SHIFT, tmpKey)
ElseIf hotKEY(1) = "CTRL" Then 'control
RegisterHotKey(Me.Handle, 100, MOD_CONTROL, tmpKey)
ElseIf hotKEY(1) = "ALT" Then 'alt
RegisterHotKey(Me.Handle, 100, MOD_ALT, tmpKey)
ElseIf hotKEY(1) = "WIN" Then 'windows key
RegisterHotKey(Me.Handle, 100, MOD_WIN, tmpKey)
End If