VB自动点击

来源:百度知道 编辑:UC知道 时间:2024/06/18 13:33:18
想了半天没想出来
界面上只有一个Timer插件
按Ctrl+Q
Timer1.Enabled=True
按Ctrl+W
Timer1.Enabled=False
Timer1需要内容:
向左移动100像素
点击
向右100像素
点击
这两个动作执行5遍
按R键
移动是指鼠标移动

窗体上添加一个Timer控件Timer1
代码如下

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private WithEvents tmrCheck As Timer
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
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 Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Sub Sleep Lib "KERNEL32" (ByVal dwMilliseconds As Long)
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private RunTime As Double

Function MyHotKey(vKeyCode) As Boolean
MyHotKey = GetAsyncKeyState(vKeyCode) < 0
End Function

Privat