Jump to content

Multi Loops


Recommended Posts

Hey guys, first post here and only started using autoit 2 days ago but so far so good until I came across a problem as I was adding more and more to my bot.

So basically I have my bot do its thing, takes about 5mins to do its job, then sit there for 2 hours, then repeat. but since I had it sitting for 2 hours i figured I might as well use the time to do something else, so I wanted to add in another loop (I've been using while/Wend) but then I wasnt even sure how that would affect it having another loop within a loop so i did a bit of searching and came up with...

For $1 = 1 To 10000
    mouseclick ( "left", 570, 390, 1) ; helper
    mouseclick ( "left", 845, 820, 1)
    mouseclick ( "left", 498, 516, 1)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    mouseclick ( "left", 847, 888, 1) ; market
    sleep (500)
    mouseclick ( "left", 746, 676, 1) ; soybeans
    mouseclick ( "left", 498, 516, 1)
    sleep (500)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    MouseClick ( "left", 900, 825, 1) ; shovel
    mouseclick ( "left", 498, 516, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 521, 529, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 545, 542, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
Next
sleep (1000)
MouseClick ( "left", 800, 822, 1) ; multi-tool

*hopefully that came out right*

So my first question is, will this script within what i've already done using while/wend cause an error?

Then I realized that in my script i have it set to sleep for 2 hours, and by adding in this new script, it would first have to loop that portion of it 10000 times before it would move to the next line which was my 2 hour break so the timing would be off...

I guess the best solution would be if there is a way I could set the loop to loop at a set time, rather than a set number of times so that i could use that as the 2 hour timer on its own... if it is possible :D thanks for any replies!

Link to comment
Share on other sites

hmm I cant locate an edit button if there is one, but I tried messing around with the script a bit more and came up with..

$Start = TimerInit()

while timerdiff($start) < 3600000
    mouseclick ( "left", 570, 390, 1) ; helper
    mouseclick ( "left", 845, 820, 1)
    mouseclick ( "left", 498, 516, 1)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    mouseclick ( "left", 847, 888, 1) ; market
    sleep (500)
    mouseclick ( "left", 746, 676, 1) ; soybeans
    mouseclick ( "left", 498, 516, 1)
    sleep (500)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    MouseClick ( "left", 900, 825, 1) ; shovel
    mouseclick ( "left", 498, 516, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 521, 529, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 545, 542, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    sleep (1000)
    MouseClick ( "left", 800, 822, 1) ; multi-tool
    
    if TimerDiff($start) > 3600000 then
        Exit
    EndIf
WEnd

would this work? I cannot test it until I get home in a couple hours so that's why I'm asking before testing in case someone was wondering o.o

Edited by IsmokeIdrank
Link to comment
Share on other sites

$Start = TimerInit()

while timerdiff($start) < 3600000
    mouseclick ( "left", 570, 390, 1) ; helper
    mouseclick ( "left", 845, 820, 1)
    mouseclick ( "left", 498, 516, 1)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    mouseclick ( "left", 847, 888, 1) ; market
    sleep (500)
    mouseclick ( "left", 746, 676, 1) ; soybeans
    mouseclick ( "left", 498, 516, 1)
    sleep (500)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
    MouseClick ( "left", 900, 825, 1) ; shovel
    mouseclick ( "left", 498, 516, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 521, 529, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 545, 542, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    sleep (1000)
    MouseClick ( "left", 800, 822, 1) ; multi-tool
    
    if TimerDiff($start) > 3600000 then
        Exit
    EndIf
WEnd

basically it have to do all that functions and then wait 2 hours?

i will do it like this:

Hotkeyset ("e","exit()")
Func helper()
    mouseclick ( "left", 570, 390, 1) ; helper
    mouseclick ( "left", 845, 820, 1)
    mouseclick ( "left", 498, 516, 1)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
Endfunc
func market()
    mouseclick ( "left", 847, 888, 1) ; market
Endfunc
func soybeans()
    mouseclick ( "left", 746, 676, 1) ; soybeans
    mouseclick ( "left", 498, 516, 1)
    sleep (500)
    mouseclick ( "left", 521, 529, 1)
    mouseclick ( "left", 545, 542, 1)
EndFunc
func shovel ()
    MouseClick ( "left", 900, 825, 1) ; shovel
    mouseclick ( "left", 498, 516, 1)
Endfunc
func okay()
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 521, 529, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    mouseclick ( "left", 545, 542, 1)
    sleep (1000)
    MouseClick ( "left", 470, 711, 1) ;okay
    sleep (1000)
Endfunc
func multitool()
    MouseClick ( "left", 800, 822, 1) ; multi-tool
Endfunc
while 1=1
helper()
market()
sleep(500)
soybeans()
shovel()
sleep(1000)
okay()
multitool()
sleep(3600000)
Wend

func exit()
exit
Endfunc

this will repeat this loop untill you Press E, the loop is actually doing all the steps you gaved me and after he finished do all the steps he wait 2 hours, then start all over again, as said above, untill you press the E button....

Link to comment
Share on other sites

Little changes. Your hotkey didn't work.

HotKeySet("e", "_exit")

While 1
    helper()
    market()
    Sleep(500)
    soybeans()
    shovel()
    Sleep(1000)
    okay()
    multitool()
    Sleep(3600000)
WEnd

Func helper()
    MouseClick("left", 570, 390, 1) ; helper
    MouseClick("left", 845, 820, 1)
    MouseClick("left", 498, 516, 1)
    MouseClick("left", 521, 529, 1)
    MouseClick("left", 545, 542, 1)
EndFunc   ;==>helper

Func market()
    MouseClick("left", 847, 888, 1) ; market
EndFunc   ;==>market

Func soybeans()
    MouseClick("left", 746, 676, 1) ; soybeans
    MouseClick("left", 498, 516, 1)
    Sleep(500)
    MouseClick("left", 521, 529, 1)
    MouseClick("left", 545, 542, 1)
EndFunc   ;==>soybeans

Func shovel()
    MouseClick("left", 900, 825, 1) ; shovel
    MouseClick("left", 498, 516, 1)
EndFunc   ;==>shovel

Func okay()
    MouseClick("left", 470, 711, 1) ;okay
    MouseClick("left", 521, 529, 1)
    Sleep(1000)
    MouseClick("left", 470, 711, 1) ;okay
    MouseClick("left", 545, 542, 1)
    Sleep(1000)
    MouseClick("left", 470, 711, 1) ;okay
    Sleep(1000)
EndFunc   ;==>okay

Func multitool()
    MouseClick("left", 800, 822, 1) ; multi-tool
EndFunc   ;==>multitool

Func _Exit()
    Exit
EndFunc   ;==>exit
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...