前面已经有人帮你回答啦,我把API这补上Option Explicit
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 _
)'Option_Tag标示选择了哪一种模拟事件
Dim Option_Tag As Integer
'OnTest标示是否处于模拟状态,以便我们停止模拟
Dim OnTest As Boolean
'对API变量的定义
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
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Form1.Timer1.Interval = Text1.Text'在text1里输入1000=1s
Form1.Timer1.Enabled = True
Command1.Caption = "关闭"
Else
Form1.Timer1.Enabled = False
Command1.Caption = "开始"
End If
End SubPrivate Sub Form_Load()
Command1.Caption = "开始"
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Command1.Value = True'快捷键:回车
End Sub
Private Sub Timer1_timer()
mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0'右击
End Sub