Sign in to follow this  
Followers 0
IsmokeIdrank

Multi Loops

5 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


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

Share this post


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

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

thanks for the replies :D I believe I got it working ^^

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