|
|
#3
lowxiong2014-04-03 20:15
新建一个工程,在窗口里放一个按钮控件,放一个标签控件(label),放一个时钟控件,拷贝下列代码,鼠标会每隔2秒钟自动点击按钮,标签里的数自动累加(手动点击按钮也会累加)
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 Sub Command1_Click()
Label1.Caption = Val(Label1.Caption) + 1
End Sub
Private Sub Form_Load()
Timer1.Interval = 2000
End Sub
Private Sub Timer1_Timer()
Dim x As Long, y As Long
x = (Me.Left + Command1.Left + 600) / 15
y = (Me.Top + Command1.Top + 600) / 15
SetCursorPos x, y
mouse_event &H2, 0, 0, 0, 0
mouse_event &H4, 0, 0, 0, 0
End Sub
|