Sign in to follow this  
Followers 0
Bizzet

Pausing While Loop?

13 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

okay everything is working great except 1 problem.

I do not need to play Loop 2 every time it pixelsearches.

I would like it play only every 30 minutes.

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