Well I have this code:
Public Sub FuncKeysModule(ByVal value As Keys)
'Check what function key is in a pressed state, and then perform the corresponding action.
Select Case value
Case Keys.F8
spam.Enabled = True
TabControl1.SelectedIndex = 0
state = "Activo"
Case Keys.F9
spam.Enabled = False
TabControl1.SelectedIndex = 1
state = "Parado"
End Select
End Sub
Private Sub frmMain_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Then
FuncKeysModule(e.KeyValue)
e.Handled = True
End If
End Sub
When I press F8 or F9 the Form call the function that you can see. But I have a dude, how can I do call it if the Form is Minimized or Unselected (if I have TopMost on True)?
Thanks. ;)
I have this code:
But everytime that I run my project an Excepcion occur, Could not set keyboard hook
What can I do? :S
It's posible, you have tu uncheck the "Enable Visual Studio hosting process" on the Properties -> Debug table of the project, and use this code:
It's works :)