作者:广东在线游戏网日期:
返回目录:游戏资讯
我会用按键精灵配合大漠插件进行后天鼠标点击,虽然不是VB,不过想法可来以分享一下。我的做法是鼠标移动到指定源坐标后,鼠标会飘移,这时我再计算鼠标到指定坐标的相对位置,然后再移一次,第二次移动时鼠标离指定坐标不远,不会漂移的太厉害,基本都能点中,你用zhidaoVB可以试试
首先要获取指定窗口的窗口句柄,然后用后台插件绑定到指定窗口。这样你用插件命令写出来的脚本就可以后台运行了。但是大多不能最小化,只能遮挡。
Option Explicit
'在VB窗体上添加两个CommandButton,使用默认名称,即可观察测试效果
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) 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 Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
Private Sub Command1_Click()
Dim Point0 As POINTAPI
Dim Point1 As POINTAPI
GetCursorPos Point0 '获取当e5a48de588b67a686964616f338前鼠标坐标
Point1.X = 2 '指定偏移坐标X值,实际应用时视目标窗体而定
Point1.Y = 2 '指定偏移坐标Y值,实际应用时视目标窗体而定
'将偏移Command2的偏移坐标转换成屏幕坐标
'实际应用时使用指定窗口的句柄
ClientToScreen Command2.hWnd, Point1
'将鼠标移动到转换后的Point1坐标,即指定窗口的偏移坐标
SetCursorPos Point1.X, Point1.Y
'模拟鼠标左键Click动作
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
'恢复原鼠标坐标
SetCursorPos Point0.X, Point0.Y
End Sub
Private Sub Command2_Click()
Debug.Print "Click"
End Sub