vb 模拟鼠标点击

如何用vb模拟鼠标在屏幕的x = 10 : y = 20 的位子上点击一下左键???
2024-12-05 04:10:22
推荐回答(2个)
回答1:

Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) 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) '定义鼠标事件
'上面的是声明部分.只有声明了,才可以使用..

'代码部分
Call SetCursorPos(10, 20)'让鼠标移动到(10,20)

mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '模拟鼠标的左键单击!

回答2:

mouse_event MOUSEEVENTF_MOVE,10,10,0,0