执行鼠标按钮单击

时间:2014-09-18 14:33:22

标签: vb.net mouseevent desktop-application

我目前正在构建一个应用程序通过键盘控制鼠标光标。我正在使用以下代码进行鼠标事件:

Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Sub Mouse_Click(ByVal button As Integer, ByVal state As String)

    Select Case button
        Case 1
            If state = "down" Then
                mouse_event(2, 100, 100, 0, 0)
            Else
                mouse_event(4, 100, 100, 0, 0)
            End If
        Case 2
            If state = "down" Then
                mouse_event(8, 100, 100, 0, 0)
            Else
                mouse_event(16, 100, 100, 0, 0)
            End If
        Case 3
            If state = "down" Then
                mouse_event(32, 100, 100, 0, 0)
            Else
                mouse_event(64, 100, 100, 0, 0)
            End If
    End Select

End Sub

之后为了执行点击:

Mouse_Click(1, "down")
Mouse_Click(1, "up")

以前的代码可以正常执行键盘上的所有鼠标按键点击。 我想做的就是:

通过按某个键盘按钮执行Mouse_Click(1, "up")

,执行长按左键单击以选择和拖动功能

我尝试了几件事但是徒劳无功。我知道答案可能很简单,但我无法达到。

提前致谢!

0 个答案:

没有答案