문제

I can't figure out how to make system to wait 10 secounds without make him to sleep (I want to make only timer2 to wait 10 seconds and after it, to start work. I tried System.Threading.Thread.Sleep(10000) but this code make all app to sleap. Here is the code from timer2

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    '1214x727
    Dim procinstall As Boolean = Process.GetProcesses().Any(Function(p) p.ProcessName.Contains("ErrorFixer"))
    If procinstall = True Then
        SetCursorPos(1214, 727)
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'Invoke mouse down event
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 'Invoke mouse up event
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'Invoke mouse down event
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 'Invoke mouse up event
        Timer2.Stop()
        Label3.Text = "Installing"
    End If
End Sub

After If procinstall = True Then, I want to put that code to wait until cursor will go to that position and mouse will click.

Thanks.

도움이 되었습니까?

해결책

Set the Timer's interval to 10000. Handle Elapsed event (for Timers.Timer).

EDIT: If you are using a Timer control on a form, the event is called Tick.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top