Jump to content

Help reset a while loop!


Recommended Posts

How do you restart a while loop after an adlibregister function activates.

The main code activates(infinite loop), however when the adlibregister actives (error check), I need the while code to start from the beginning. So how do i exit the current while loop, and restart it?

Link to comment
Share on other sites

Post the code you have so far (regardless of how little it may be) so we can be more helpful, as of now the best advice is that you look in the help-file for ExitLoop and maybe ContinueLoop. :)

Link to comment
Share on other sites

AdlibRegister("_MyFunc")

Global $Condition1 = True

While 1
    $Timer = TimerInit()
    If $Condition1 Then
        ConsoleWrite("Working" & @CRLF)
        Sleep(2000)
    EndIf
WEnd

Func _MyFunc()
    $Condition1 = Not $Condition1
    If $Condition1 Then
        ConsoleWrite("Sleeping 1000" & @CRLF)
    EndIf
EndFunc

You have to add your own logic of course.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

The while loops works perfectly, but after the adlibregister checks for the error, it pauses the loop, i want it to exit it instead of resuming where it left off.

AdlibRegister("errorcheck", 1000)

Func errorcheck()

    If $errorcheck1 <> 0 Then
        Sleep(5000)
        $start = 0
        $errorcheck2 = PixelSearch(350, 305, 690, 500, 0xf5e9a4, 0)
        If $errorcheck2 <> 0 Then
            MouseClick("left", 520, 480, 1)
            $start = 1
        EndIf
    EndIf
EndFunc

Func runprogram()


    $guicheck1 = PixelSearch(350, 305, 690, 500, 0xC94336, 0)


    While $check = 1

        While 1 = 1
            MouseClick("left", 100, 680, 1)
            Send($trans)
            MouseClick("left", 280, 740, 1)
        WEnd
    WEnd

EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...