以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  移动鼠标坐标  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127986)

--  作者:yangwenghd
--  发布时间:2018/11/26 16:22:00
--  移动鼠标坐标
老师能请教一个功能吗?就是点击按钮可以把鼠标移动到窗口的某个坐标或者某个指定的位置吗?感谢 感谢。
--  作者:有点甜
--  发布时间:2018/11/26 16:31:00
--  

模拟鼠标点击参考

 

全局代码

 

Public 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)
Public const MOUSEEVENTF_MOVE As Int32 = &H1 \'  mouse move
Public const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 \'  left button down
Public const MOUSEEVENTF_LEFTUP As Int32 = &H4 \'  left button up
Public const MOUSEEVENTF_RIGHTDOWN As Int32 = &H8 \'  right button down
Public const MOUSEEVENTF_RIGHTUP As Int32 = &H10 \'  right button up
Public const MOUSEEVENTF_MIDDLEDOWN As Int32 = &H20 \'  middle button down
Public const MOUSEEVENTF_MIDDLEUP As Int32 = &H40 \'  middle button up
Public const MOUSEEVENTF_ABSOLUTE As Int32 = &H8000 \'  absolute move
Public const MOUSEEVENTF_WHEEL As Int32 = &H800 \' wheel button rolled

<DllImport("user32.dll", EntryPoint := "SetCursorPos")> _
Public Function SetCursorPos(x As Integer, y As Integer) As Boolean

End Function

 

调用

 

SetCursorPos (599, 589) \'鼠标位置
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) \'点击
mouse_event (MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)


--  作者:yangwenghd
--  发布时间:2018/11/26 16:47:00
--  
感谢 感谢 又学到了,感谢老师