就是鼠标自动点击5个位置,都是单击 时间间隔1秒点一次
如此循环按下command1开始 在按下就停止
5个位置的鼠标坐标我自己找就可以
现在只能循环点击两个点,再多就不会编了Private Sub Command1_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
Timer2.Interval = 1000
Timer2.Enabled = True
End SubPrivate Sub Timer1_Timer()
Dim a As Integer
Static b As Integer
' a = Val(Text1.Text)
' b = 0
' Do Until b = a
b = b + 1
SetCursorPos 916, 535
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Print "click " & b
' Loop
End SubPrivate Sub Timer2_Timer()
Dim a As Integer
Static b As Integer
SetCursorPos 208, 642
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Print "click " & b
' Loop
End Sub 
 
 

解决方案 »

  1.   

    用 循环
    Private Sub Timer1_Timer()
    for i=0 to j-1'j为几个点
    select case i
    case 1
    Dim a As Integer
    Static b As Integer
    SetCursorPos 208, 642
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    Print "click " & b
    case 2
    case 3
    case 4
    .
    .
    .
    .
    end select
    if x=j-1 then
    x=0
    end if
    next
    End Sub
      

  2.   

    这个  失误 case 0开始~
      

  3.   

    谢谢,我把你的代码整个的贴到了timer1
    运行后只点击一个位置
    怎样点5个位置 其他的坐标从哪里填    SetCursorPos 208, 642就这个
    Private Sub Timer1_Timer()
    For i = 0 To 5 - 1
    Select Case i
    Case 0
    Dim a As Integer
    Static b As Integer
    SetCursorPos 208, 642
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    Print "click " & b
    Case 1
    Case 2
    Case 3
    Case 4
    Case 5
    End Select
    If x = 5 - 1 Then
    x = 0
    End If
    Next
    End Sub
     
      

  4.   

    建议不要用for循环
    使用静态变量 加载窗体时设为0
    然后在timer事件里加入如下判断
    if num>5 then num=1
    select case num
    case 1
    .
    .
    .
    end select
    num=num+1