资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net模拟鼠标单击 vba模拟鼠标双击

如何在VB.net中用程序控制鼠标移动和点击

调用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)模拟鼠标左键按下

vb.net中,如何实现鼠标在listbox控件上移动时,鼠标所到的条目背景变黑、字变白;移开后还原?

复杂的不会,来点儿简单的,借用在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

VB.net鼠标事件模拟问题

直接把消息发送给TextBox。

Dim x As Integer, y As Integer

x = 100

y = 100

PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONDOWN, MK_LBUTTON, MakeInteger(x, y))

PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONUP, MK_LBUTTON, MakeInteger(x, y))

VB.NET模拟鼠标问题

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)

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 的详解,大致使用如上


网站标题:vb.net模拟鼠标单击 vba模拟鼠标双击
URL分享:http://cdkjz.cn/article/dopgedp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220