展开全部
'添加一下 控件 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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哎,同样问题求助啊,和LZ一起等待高人解答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询