Sign in to follow this  
Followers 0
anthonyjr2

Looping back

4 posts in this topic

#1 ·  Posted (edited)

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=

Share this post


Link to post
Share on other sites



Looks like a game bot.

Rules:

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


#include <ByteMe.au3>

Share this post


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


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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=

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