我想要做的是在后台运行一个应用程序,该应用程序在键盘上按下捕获键,然后双击发送到 Windows im on(不是 vb 程序)中的 X 和 Y 坐标。
这是我到目前为止所拥有的:
Public Class Form1
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As System.Windows.Forms.Keys) As Integer
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 IntPtr)
Private Sub PerformMouseClick(ByVal LClick_RClick_DClick As String, ByVal xCoord As Integer, ByVal yCoord As Integer)
Const MOUSEEVENTF_LEFTDOWN As Integer = 2
Const MOUSEEVENTF_LEFTUP As Integer = 4
Const MOUSEEVENTF_RIGHTDOWN As Integer = 6
Const MOUSEEVENTF_RIGHTUP As Integer = 8
If LClick_RClick_DClick = "RClick" Then
mouse_event(MOUSEEVENTF_RIGHTDOWN, xCoord, yCoord, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_RIGHTUP, xCoord, yCoord, 0, IntPtr.Zero)
ElseIf LClick_RClick_DClick = "LClick" Then
mouse_event(MOUSEEVENTF_LEFTDOWN, xCoord, yCoord, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_LEFTUP, xCoord, yCoord, 0, IntPtr.Zero)
ElseIf LClick_RClick_DClick = "DClick" Then
mouse_event(MOUSEEVENTF_LEFTDOWN, xCoord, yCoord, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_LEFTUP, xCoord, yCoord, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_LEFTDOWN, xCoord, yCoord, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_LEFTUP, xCoord, yCoord, 0, IntPtr.Zero)
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetAsyncKeyState(Keys.W) Then
PerformMouseClick("LClick", 74, 1103)
End If
End Sub
End Class
但双重不会发生。键(W)在我的 vb 之外被识别,这一切都很好。我只是不知道如何在坐标处双击。有人有想法吗?