重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
十多年的岳阳楼网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整岳阳楼建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“岳阳楼网站设计”,“岳阳楼网站推广”以来,每个客户项目都认真落实执行。
Dim postion1 As New Point
mouse_event(H1 Or H8000, postion1.X * 65535 / 1366, postion1.Y * 65535 / 768, 0, 0)
'按绝对位置移动鼠标
'在鼠标坐标系统中,屏幕在水平和垂直方向上均匀分割成65535×65535个单元,
'当前所用显示屏分辨率为1366*768
'所以要进行如上转换
mouse_event(H2, 0, 0, 0, 0) '鼠标左键按下
mouse_event(H4, 0, 0, 0, 0) '鼠标左键弹起
msdn上有 mouse_event 的详解,大致使用如上
在事件里要记住鼠标的移动轨迹数据并保存到数组里,再用这些数据操作鼠标就是模拟鼠标还原了
还原时要有个时间控制 也就是每秒录制几个鼠标坐标 还原时每秒就移动几个坐标,思路就这样了
复杂的不会,来点儿简单的,借用在listbox里按下鼠标时再移动,会高亮显示选择行,并且会随鼠标移动而变化的这一特点改进的,不足之处是在listbox里,此时处于鼠标左键在按下状态。
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_LEFTDOWN = H2 '模拟鼠标左键按下
Private Sub ListBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseMove
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub
调用api
在Visual Baisc.net中的声明:
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_LEFTDOWN = H2 '模拟鼠标左键按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模拟鼠标左键释放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模拟鼠标中间键按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模拟鼠标中间键释放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模拟鼠标右键按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模拟鼠标右键释放
Public Const MOUSEEVENTF_MOVE = H1 '模拟鼠标指针移动
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模拟鼠标左键按下