Sign in to follow this  
Followers 0
jpnguyen21

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

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
Share on other sites

Having trouble trying to figure out how to restart a script.

(What do I put here to get the script to start at line 1 again)

Perhaps this'll help - Re-Start your Program.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

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