1
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyDown    
    If Keys.Control And Keys.Alt And Keys.Shift And Keys.N Then
        Me.Opacity = 100
        Me.ShowInTaskbar = True
        Me.ShowIcon = True
        MsgBox("CTRL + ALT + SPACE") ' This work
        Me.BackColor = Color.Indigo
        CheckBox3.Checked = False
    End If
End Sub

i use question I want the keyboard to listen to multiple keys when it's in the background, but this doesn't work. What's wrong?

  • 2
    Just to be sure, what is `kbHook` in this case? Is that some kind of library you've added that installs an actual **keyboard hook**? If so, can you link to the source or documentation? – Idle_Mind Jun 06 '19 at 13:49
  • Same thing goes for `Keys`...where did that come from? – Idle_Mind Jun 06 '19 at 13:51
  • 1
    It looks like this [answer](https://stackoverflow.com/a/15038869/832052) to this [question](https://stackoverflow.com/q/15038413/832052) is where you got your code. Its pretty well received so it should work. Did you make sure to `Project -> [Project Name] Properties -> Debug -> Uncheck “Enable the Visual Studio hosting process”` according to the comment? – djv Jun 06 '19 at 14:18
  • yes djv but " Enable the Visual Studio hosting process " was removed in Visual Studio 2017 (i use vb 2007) and i don't know how to make a program to wait until all key such as ctrl,shft,alt and h, `If Keys.Control And Keys.Alt And Keys.Shift And Keys.N` can't work , also `if e.contol .....` can't work – monkey from Tanzania Jun 07 '19 at 08:13
  • sorry @Idle_Mind i edit question – monkey from Tanzania Jun 07 '19 at 08:17

1 Answers1

2

This works for me:

Private Sub kbHook_KeyDown(Key As Keys) Handles kbHook.KeyDown
    If My.Computer.Keyboard.CtrlKeyDown AndAlso
        My.Computer.Keyboard.AltKeyDown AndAlso
        My.Computer.Keyboard.ShiftKeyDown AndAlso
        Key = Keys.N Then

        Debug.Print("Ctl-Alt-Shift-N")

    End If
End Sub
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40