VB鼠标的移动,点击
VB高手,请大家给小弟几个实例,我是初学者。做以参考,我想单击键盘里的F1键后,鼠标自动移动到屏幕中的X:1050.Y:522然后左键单击,第2个例子,,,按下F2后,鼠...
VB高手,请大家给小弟几个实例,我是初学者。做以参考, 我想单击键盘里的F1键后,鼠标自动移动到屏幕中的 X:1050.Y:522 然后左键单击, 第2个例子,,,按下F2后 ,鼠标到X:568.Y:126 然后右键单击, 请高手多给几个例子。谢谢了
展开
1个回答
展开全部
声明
Declare
Function
GetPrivateProfileString&
Lib
"kernel32"
Alias
"GetPrivateProfileStringA"
(ByVal
lpApplicationName
As
String,
ByVal
lpKeyName
As
String,
ByVal
lpDefault
As
String,
ByVal
lpReturnedString
As
String,
ByVal
nSize
As
Long,
ByVal
lpFileName
As
String)
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)
Const
MOUSEEVENTF_LEFTDOWN
=
&H2
'
left
button
down
Const
MOUSEEVENTF_LEFTUP
=
&H4
'
left
button
up
程序中
SetCursorPos
455,
234
'你所需要点的位置
mouse_event
MOUSEEVENTF_LEFTDOWN
Or
MOUSEEVENTF_LEFTUP,
0&,
0&,
0&,
0&
'模拟鼠标点击
如果要模拟键盘操作就换一个函数
换成keyboard_event
Declare
Function
GetPrivateProfileString&
Lib
"kernel32"
Alias
"GetPrivateProfileStringA"
(ByVal
lpApplicationName
As
String,
ByVal
lpKeyName
As
String,
ByVal
lpDefault
As
String,
ByVal
lpReturnedString
As
String,
ByVal
nSize
As
Long,
ByVal
lpFileName
As
String)
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)
Const
MOUSEEVENTF_LEFTDOWN
=
&H2
'
left
button
down
Const
MOUSEEVENTF_LEFTUP
=
&H4
'
left
button
up
程序中
SetCursorPos
455,
234
'你所需要点的位置
mouse_event
MOUSEEVENTF_LEFTDOWN
Or
MOUSEEVENTF_LEFTUP,
0&,
0&,
0&,
0&
'模拟鼠标点击
如果要模拟键盘操作就换一个函数
换成keyboard_event
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询