如何在VB.net中用程序控制鼠标移动和点击
2个回答
展开全部
调用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)模拟鼠标左键按下
在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)模拟鼠标左键按下
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询