我正在用 VB6 编写一个自动点击程序。这个想法是,如果我在按住左键的同时按住右键,它会自动开始点击,直到你放开任何一个。
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Dim lefter As Boolean, righter As Boolean
Public Sub LeftClick()
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub Form_Load()
lefter = False
righter = False
Timer1.Interval = 80
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(2) = 0 Then
righter = False
Else: righter = True
End If
If GetAsyncKeyState(1) = 0 Then
lefter = False
Else: lefter = True
End If
If lefter = True Then
If righter = True Then
LeftClick
End If
End If
End Sub
Timer1 每 80 毫秒触发一次。
这个东西很好用,直到我尝试通过释放左键(同时继续按住右键)来停止它,程序似乎在启动后完全忽略了它。
相对而言,这几乎不是问题,也很容易解决,但我宁愿修复它,这样我就根本不必解决它。
先感谢您。