VB模拟鼠标点击

鼠标在x1,y1按下左键延迟1秒然后移动到x2,y2释放左键代码月简单越好... 鼠标在x1,y1按下左键
延迟1秒
然后移动到x2,y2释放左键

代码月简单越好
展开
 我来答
哥哥好酷
推荐于2016-06-13 · TA获得超过508个赞
知道小有建树答主
回答量:162
采纳率:0%
帮助的人:209万
展开全部
'添加一下 控件 command1 timer1

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)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4

Private Sub Command1_Click()
SetCursorPos 100, 110 ' x1,y1
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '鼠标按下左键
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
SetCursorPos 200, 210 'x2,y2
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '鼠标释放左键
Timer1.Enabled = False
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友84e7879742e
2019-04-14 · TA获得超过3720个赞
知道大有可为答主
回答量:2980
采纳率:28%
帮助的人:157万
展开全部
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)
Private
Declare
Sub
Sleep
Lib
"kernel32"
(ByVal
dwMilliseconds
As
Long)
Private
Sub
Command1_Click()
AutoPressMouse
125,
159
Sleep
3000
AutoPressMouse
165,
254
End
Sub
Private
Sub
AutoPressMouse(x
As
Long,
y
As
Long)
SetCursorPos
x,
y
'
mouse_event
MOUSEEVENTF_LEFTDOWN
Or
MOUSEEVENTF_LEFTUP,
0,
0,
0,
0
mouse_event
MOUSEEVENTF_LEFTDOWN,
0,
0,
0,
0
mouse_event
MOUSEEVENTF_LEFTUP,
0,
0,
0,
0
End
Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
雨水沉没
2010-01-07 · TA获得超过142个赞
知道小有建树答主
回答量:216
采纳率:0%
帮助的人:149万
展开全部
哎,同样问题求助啊,和LZ一起等待高人解答
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式