创建全局HotKeys VB.Net

时间:2017-07-01 14:16:00

标签: vb.net keyboard-shortcuts

我有一个代码可以在按下某个键时启动计时器

代码:

Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    If GetKeyPress(Keys.LControlKey)  Then
        Timer1.Start()
    ElseIf GetKeyPress(Keys.LShiftKey) Then
        MsgBox("test")
    End If
End Sub

这里的问题是我按左控制计时器1启动并且消息框也出现而没有单击左移。请帮助。

0 个答案:

没有答案