Jump to content

Looping back


Recommended Posts

I have this code I am writing, and I want it to finish the if statement, and then run through again if the script finds another image. Here is the code:

While 1
    $pos= MouseGetPos()
    Send ("{F3}{ALTDOWN}{CTRLDOWN}")
    Sleep (1000)
    MouseClick ("left",$pos[0],$pos[1],4,50)
    Sleep (100)
    Send ("{CTRLUP}")
    Sleep (8000)
$result = _ImageSearch("Fomor.png",1,$x1,$y1,100)
    if $result Then
        MouseMove($x1,$y1)
        MouseClick("left",$x1,$y1,2)
        sleep(1000)
    EndIf
$result = _ImageSearch("Gold.png",1,$x1,$y1,100)
    if $result Then
        MouseMove($x1,$y1)
        MouseClick("left",$x1,$y1,2)
        sleep(1000)
    EndIf
$result = _ImageSearch("Potion.png",1,$x1,$y1,100)
    if $result Then
        MouseMove($x1,$y1)
        MouseClick("left",$x1,$y1,2)
        sleep(1000)
    EndIf
    Send ("{ALTUP}")
WEnd

I want it to go through this loop, and when it gets to any EndIf, to repeat back to either the If statement it is on, or first one. I just do not want it to go back to the beginning of the While loop. Basically, there are two of each image on the screen. It goes through and gets one of each of them, but not the others without going back to the beginning of the loop. It needs to go back to the beginning of the If and start from there again, until it doesn't get a result anymore from the search. I'm really new to this autoit stuff so I don't really know much yet.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Link to comment
Share on other sites

While 1
    $pos = MouseGetPos()
    Send("{F3}{ALTDOWN}{CTRLDOWN}")
    Sleep(1000)
    MouseClick("left", $pos[0], $pos[1], 4, 50)
    Sleep(100)
    Send("{CTRLUP}")
    Sleep(8000)
    While _ImageSearch("Fomor.png", 1, $x1, $y1, 100)
        MouseMove($x1, $y1)
        MouseClick("left", $x1, $y1, 2)
        Sleep(1000)
    WEnd
    While _ImageSearch("Gold.png", 1, $x1, $y1, 100)
        MouseMove($x1, $y1)
        MouseClick("left", $x1, $y1, 2)
        Sleep(1000)
    WEnd
    While _ImageSearch("Potion.png", 1, $x1, $y1, 100)
        MouseMove($x1, $y1)
        MouseClick("left", $x1, $y1, 2)
        Sleep(1000)
    WEnd
    Send("{ALTUP}")
WEnd

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Looks like a game bot.

Rules:

http://www.autoitscript.com/forum/forum-2/announcement-13-forum-rules/

Oh sorry, I was in such a hurry to try to fix this I didn't read the rules. Disregard my entire post then and I will be off.

EDIT: And to forumer, thank you for the help, I didn't think of using that many While statements.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

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...