vbs/vb如何模拟鼠标点击
易语言有个模拟鼠标点击,请问如何在vbs或vb中实现(最好是vbs的)注意:不是模拟键盘点击最好不要是太复杂的,哪个简单就采纳哪个MassacreWar-的不错...
易语言有个模拟鼠标点击,请问如何在vbs或vb中实现(最好是vbs的)
注意:不是模拟键盘点击
最好不要是太复杂的,哪个简单就采纳哪个
MassacreWar -的不错 展开
注意:不是模拟键盘点击
最好不要是太复杂的,哪个简单就采纳哪个
MassacreWar -的不错 展开
4个回答
展开全部
vb6的
相关的api
'模拟鼠标事件
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 Type POINTAPI
X As Long
Y As Long
End Type
'设置鼠标光标的坐标(位置)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
'设置鼠标光标的坐标(位置)
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
'获取鼠标的位置
Dim p As POINTAPI
Call GetCursorPos(p)
Text1.Text = p.X
Text2.Text = p.Y
'设置鼠标的光标到坐标(431, 190)位置
ret = SetCursorPos(431, 190)
'模拟一个左键单击的事件
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
其它的自己可以对照着api自己摸索了。。。
相关的api
'模拟鼠标事件
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 Type POINTAPI
X As Long
Y As Long
End Type
'设置鼠标光标的坐标(位置)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
'设置鼠标光标的坐标(位置)
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
'获取鼠标的位置
Dim p As POINTAPI
Call GetCursorPos(p)
Text1.Text = p.X
Text2.Text = p.Y
'设置鼠标的光标到坐标(431, 190)位置
ret = SetCursorPos(431, 190)
'模拟一个左键单击的事件
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
其它的自己可以对照着api自己摸索了。。。
推荐于2017-09-11 · 知道合伙人数码行家
可以叫我表哥
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:25897
获赞数:1464984
2010年毕业于北京化工大学北方学院计算机科学与技术专业毕业,学士学位,工程电子技术行业4年从业经验。
向TA提问 私信TA
关注
展开全部
参考代码如下:
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Sub Command1_Click()
MsgBox "123"
End Sub
Private Sub Command2_Click()
PostMessage Command1.hwnd, WM_LBUTTONDOWN, 0, 0
PostMessage Command1.hwnd, WM_LBUTTONUP, 0, 0
End Sub
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Sub Command1_Click()
MsgBox "123"
End Sub
Private Sub Command2_Click()
PostMessage Command1.hwnd, WM_LBUTTONDOWN, 0, 0
PostMessage Command1.hwnd, WM_LBUTTONUP, 0, 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Function Click() '定义模拟鼠标单击
mouse_event 6, 0, 0, 0, 0
End Function
mouse_event 6, 0, 0, 0, 0
End Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Function Click() '定义模拟鼠标单击
mouse_event 6, 0, 0, 0, 0
End Function
Function Click() '定义模拟鼠标单击
mouse_event 6, 0, 0, 0, 0
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询