Sign in to follow this  
Followers 0
BeautifulWar

Help reset a while loop!

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

If $Conditon1 Then

While 1

;stuff

If $Condition2 Then

ExitLoop

EndIf

EndIf

Sorry, but that isn't very helpful. I want the adlibregister to restart or exit the loop Edited by BeautifulWar

Share this post


Link to post
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. :)

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0