Jump to content

Pausing While Loop?


Bizzet
 Share

Recommended Posts

While 1
Sleep(1000)
PixelSearch ($pos[0], $pos[1], $pos[0], $pos[1], 0xEEEEFF)
;If it does find the the white pixel, then the loop will continue.
If Not @error Then
ContinueLoop
;If PixelSearch does not find the white pixel it will execute the following.
ElseIf @error Then
Send("{ENTER}")
Sleep(1111)
MouseClick("left", 666, 58, 1)
Sleep(1111)
MouseClick("left", 652, 90, 1)
Sleep(500)
MouseClick("left", 247, 269, 1)
Sleep(500)
Send("{TAB}")
Send("11111111111")
Sleep(100)
Send("{ENTER}")
Sleep(110)
MouseClick("left", 330, 151, 2)

ExitLoop
EndIf
WEnd

I'm sure the code above matters in no way but I thought you MAY need to see what I am looping.

My question is, How would I pause this loop every so often to play another loop until it finishes, then continue pixelsearching with the above loop?

Edited by Bizzet
Link to comment
Share on other sites

This?

While 1
    PixelSearch($pos[0], $pos[1], $pos[0], $pos[1], 0xEEEEFF)

    meaningful_function_name()

    ;If it does find the the white pixel, then the loop will continue.
    If Not @error Then
        ContinueLoop
        ;If PixelSearch does not find the white pixel it will execute the following.
    ElseIf @error Then
        Send("{ENTER}")
        Sleep(1111)
        MouseClick("left", 666, 58, 1)
        Sleep(1111)
        MouseClick("left", 652, 90, 1)
        Sleep(500)
        MouseClick("left", 247, 269, 1)
        Sleep(500)
        Send("{TAB}")
        Send("11111111111")
        Sleep(100)
        Send("{ENTER}")
        Sleep(110)
        MouseClick("left", 330, 151, 2)

        ExitLoop
    EndIf
WEnd

Func meaningful_function_name()
    While True
        ; useful statement
        ; useful statement
        ; useful statement
        ; useful statement
    WEnd
EndFunc

Link to comment
Share on other sites

I think the while loop is flawed

If Not @error Then
ContinueLoop
;If PixelSearch does not find the white pixel it will execute the following.
ElseIf @error Then

That means that if the pixel is found, the loop will begin again without carrying out the mouseclick operations

you need to reverse your logic.

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

This?

While 1
    PixelSearch($pos[0], $pos[1], $pos[0], $pos[1], 0xEEEEFF)

    meaningful_function_name()

    ;If it does find the the white pixel, then the loop will continue.
    If Not @error Then
        ContinueLoop
        ;If PixelSearch does not find the white pixel it will execute the following.
    ElseIf @error Then
        Send("{ENTER}")
        Sleep(1111)
        MouseClick("left", 666, 58, 1)
        Sleep(1111)
        MouseClick("left", 652, 90, 1)
        Sleep(500)
        MouseClick("left", 247, 269, 1)
        Sleep(500)
        Send("{TAB}")
        Send("11111111111")
        Sleep(100)
        Send("{ENTER}")
        Sleep(110)
        MouseClick("left", 330, 151, 2)

        ExitLoop
    EndIf
WEnd

Func meaningful_function_name()
    While True
        ; useful statement
        ; useful statement
        ; useful statement
        ; useful statement
    WEnd
EndFunc

The two functions can not be played at the same time.

Loop 2 (as I will name it for now) need to be played while Loop 1 is stopped.

When Function 2 Loop is done executing it's functions, I would like Loop 1 to continue.

Link to comment
Share on other sites

I think the while loop is flawed

If Not @error Then
ContinueLoop
;If PixelSearch does not find the white pixel it will execute the following.
ElseIf @error Then

That means that if the pixel is found, the loop will begin again without carrying out the mouseclick operations

you need to reverse your logic.

No, it is right.

I want the mouseclicks to play when the white pixel disappears.

Link to comment
Share on other sites

The two functions can not be played at the same time.

Loop 2 (as I will name it for now) need to be played while Loop 1 is stopped.

When Function 2 Loop is done executing it's functions, I would like Loop 1 to continue.

LaCastiglione code does just that, when the func returns, your main loop will continue.

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

WHen it gets to meaningful_function_name then loop1 does stop while loop2 is playing then it returns control back to loop1

Edit: yeah, what he ^^^ said...

Edited by LaCastiglione
Link to comment
Share on other sites

The two functions can not be played at the same time.

Loop 2 (as I will name it for now) need to be played while Loop 1 is stopped.

When Function 2 Loop is done executing it's functions, I would like Loop 1 to continue.

Well since you can't have two loops at once...
Link to comment
Share on other sites

My current code is

While 1
Sleep(1000)
PixelSearch ($pos[0], $pos[1], $pos[0], $pos[1], 0xEEEEFF)

Restart()
;If it does find the the white pixel, then the loop will continue.
If Not @error Then
ContinueLoop
;If PixelSearch does not find the white pixel it will execute the following.
ElseIf @error Then
Send("{ENTER}")
Sleep(1111)
MouseClick("left", 666, 58, 1)
Sleep(1111)
MouseClick("left", 652, 90, 1)
Sleep(500)
MouseClick("left", 247, 269, 1)
Sleep(500)
Send("{TAB}")
Send("11111111111")
Sleep(100)
Send("{ENTER}")
Sleep(110)
MouseClick("left", 330, 151, 2)

ExitLoop
EndIf
WEnd

Func Restart()
While True
Sleep(5000)
While 1
Send("{ENTER}")
Sleep(1000)
Send("{ENTER}")
Sleep(222)
Send("{ALT}")
Sleep(750)
MouseClick("left", 655, 88, 2)
Sleep(111)
MouseClick("left", 779, 57, 2)
Sleep(500)
Send("Bizzer")
Sleep(100)
MouseClickDrag ("left", 396, 251, 674, 471)
WEnd
EndFunc

I get an error of "While has no matching Wend statement"

It says the error is on the line of the last "EndFunc"

I'm sort of lost on what to do because I thought I added "WEnd" ?

Edited by Bizzet
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...