VB的鼠标事件
答案:2 悬赏:60 手机版
解决时间 2021-03-26 17:28
- 提问者网友:温柔港
- 2021-03-25 22:15
VB的鼠标事件
最佳答案
- 五星知识达人网友:煞尾
- 2021-03-25 22:32
在通过声明区加入以下代码:
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
加入按钮的CLICK事件
Private Sub Command1_Click()
Dim x As Long ‘想单击区域的X坐标,以像素为单位
Dim y As Long‘想单击区域的Y坐标,以像素为单位
x = 10
y = 10
SetCursorPos x, y
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
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
加入按钮的CLICK事件
Private Sub Command1_Click()
Dim x As Long ‘想单击区域的X坐标,以像素为单位
Dim y As Long‘想单击区域的Y坐标,以像素为单位
x = 10
y = 10
SetCursorPos x, y
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
全部回答
- 1楼网友:蓝房子
- 2021-03-25 22:45
Private Sub Command1_Click()
Call Command2_Click
End Sub
Private Sub Command2_Click()
Label1.Caption = "单击的"
End Sub
这个就是按了按钮1,等于按了2
Call Command2_Click
End Sub
Private Sub Command2_Click()
Label1.Caption = "单击的"
End Sub
这个就是按了按钮1,等于按了2
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯