Jump to content

loop statement help needed


Recommended Posts

heres my script....

sleep (5000)

$pixel = 13816329

for $r = 1 to 4500

$a = pixelsearch (841,508,850,513,$pixel,5)

if @error Then

mousemove (870,358)

sleep (1000)

mouseclick ("left")

Else

mousemove ($a[0],$a[1])

sleep (800)

mouseclick ("left")

sleep (800)

mouseclick ("left")

sleep (2500)

Endif

Next

if it goes to the if @error part of it...it messes the loop up...like if i set it to loop 5 times and it goes to the @error part....itll only repeat 3 times...iono what to do...help please!

Link to comment
Share on other sites

Please try to explain yourself better. What are you trying to accomplish and what is the current result?

This is also a dupe: Someone help me fix my loop!

@panthersbball44: Your code will run the loop exactly the number of times you specified in the 'For' line. Each time it will either run the top part of the 'If' or the bottom part ('Else'). Do you mean you want the loop to continue until the bottom part has executed a certain number of times? That would look like this:

$r = 0
Do
    $a = PixelSearch(841, 508, 850, 513, $pixel, 5)
    If @error Then
        MouseMove(870, 358)
        Sleep(1000)
        MouseClick("left")
    Else
        MouseMove($a[0], $a[1])
        Sleep(800)
        MouseClick("left")
        Sleep(800)
        MouseClick("left")
        Sleep(2700)
        $r += 1
    EndIf
Until $r = 5

If that's not it, explain which part you want to count the executions for.

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...