参考代码如下:
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 Command1hwnd, WM_LBUTTONDOWN, 0, 0
PostMessage Command1hwnd, WM_LBUTTONUP, 0, 0
End Sub
vbs的话需要调用API,vba不行,vba只能支持在自定义的窗体或者区域控制
vbs我不会调用api脚本模拟键盘 *** 作还是简单点的,你可以考虑能否用键盘 *** 作替代鼠标控制将问题转化为控制按键输入
不知道你要做什么,要是自己电脑需要的话,可以下个
按键精灵8
来搞
VBSCall
Call
SetCursorPos
VBSCall
Call
SetCursorPos(CursorX,CursorY)
'这个函数用来设置鼠标当前位置
VBSCall
Call
GetCursorPos
这个功能允许您得到当前鼠标所在的位置,并保存在变量中
格式
VBSCall
Call
GetCursorPos(x,y)
x和y都是整数型变量,分别表示当前鼠标的x和y坐标
您可以随便取变量名,不一定是x和y
例子
VBSCall
Call
GetCursorPos(mx,my)
把当前鼠标位置的x和y坐标放在变量mx和my中
给我加分呀
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)
Text1Text = pX
Text2Text = pY
'设置鼠标的光标到坐标(431, 190)位置
ret = SetCursorPos(431, 190)
'模拟一个左键单击的事件
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
其它的自己可以对照着api自己摸索了。。。
用循环呀do VBSCall Call FindPic(0,0,1000,700,"D:\My Documents\My Pictures\qqbmp",09,x,y)
If x>0 and y>0 then MoveTo x,yk=tureend if if k=ture then exit doloop
以上就是关于求VBS,运行后在当前位置进行鼠标单击 *** 作全部的内容,包括:求VBS,运行后在当前位置进行鼠标单击 *** 作、如何用VBS或者VBA实现对鼠标的控制、按键精灵”一键获取当前鼠标的坐标和颜色”语句是什么等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)