Quantcast
Viewing all articles
Browse latest Browse all 15648

VS 2015 Waking thread before thread sleep time finishes

Hi everyone
I'm writing an auto clicker to do a repetitive task which needs a specific time before repeating the macro
I built it but I ran through a problem
sometimes I need to stop the macro while it's in the
Code:

Thread.Sleep(140000)
part of the code
I tried using a combination of do untils and timers and counters but it seems that
Code:

Thread.Sleep(140000)
affects this too.
I tried googling for a solution but all the pages I found were excel related.
How can i fix this ?
Here's the code :
Code:

If GetAsyncKeyState(Keys.F9) Then
                Do Until GetAsyncKeyState(Keys.F8)
                    For Each line As String In File.ReadLines(Application.StartupPath & "\Macros\" & ComboBox1.Text)
                        If line.Length > 2 Then
                            Dim g = Regex.Replace(line, "[\{\}a-zA-Z=()]", "").Split(","c)
                            Dim pointResult As Point = New Point(Integer.Parse(g(0)), Integer.Parse(g(1)))
                            System.Windows.Forms.Cursor.Position = pointResult
                            Thread.Sleep(2500)
                            LeftClick()
                            If GetAsyncKeyState(Keys.F8) Then
                                Macro.Enabled = False
                                Macro.Stop()
                                N = 0
                                Exit Do
                            End If
                        Else
                            Thread.Sleep(1000)
                        End If
                    Next
                    Thread.Sleep(140000) 'here where i want to stop the thread.sleep by keybord input for ex 'F8

                Loop
            End If

thanks

Viewing all articles
Browse latest Browse all 15648

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>