Jump to content

New to Autoit, need help with a "IF, Then, (Loop)"


Recommended Posts

Having trouble trying to figure out how to restart a script. I'd like the script to start at the beginning assuming the color is found. I've tried searching and haven't found something similar.

; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0xff1f00 )
If Not @error Then
sleep ("5000")
Mouseclick ("left", "740", "571", "1", "1")
Mouseclick ("left", "1095", "655", "1", "1")
EndIf
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0x2B2F18 )
If Not @error Then
sleep ("5000")
Mouseclick ("left", "740", "571", "2", "4")
Mouseclick ("left", "1095", "655", "2", "4")
Endif
Sleep ("10000")
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0xff1f00 )
If Not @error Then
[u](What do I put here to get the script to start at line 1 again)[/u]
EndIf
Edited by jpnguyen21
Link to post
Share on other sites

Use a While/WEnd loop.

While
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0xff1f00 )
If Not @error Then
sleep ("5000")
Mouseclick ("left", "740", "571", "1", "1")
Mouseclick ("left", "1095", "655", "1", "1")
EndIf
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0x2B2F18 )
If Not @error Then
sleep ("5000")
Mouseclick ("left", "740", "571", "2", "4")
Mouseclick ("left", "1095", "655", "2", "4")
Endif
Sleep ("10000")
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 747, 69, 777, 85, 0xff1f00 )
if @error then exitloop
WEnd
Link to post
Share on other sites

jpnguyen21,

If you use the loop that ChrisN is suggesting put a sleep(100) stmt within the loop and outside of the if stmts to control CPU usage.

kylomas

Edit: Opps, I see that ChrisN has the correct code...

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...