Sign in to follow this  
Followers 0
Ixen

Need Help with Looping

18 posts in this topic

Hello,

I'm currently working on an AutoIt script to do something in a game for me and I can't seem to figure out how to loop my script (I'm going for infinite loops).

The directory to the .exe is:

C:\Documents and Settings\Greg\Desktop\Coding\MAcros\SWG.exe

I have tried Run, RunWait, and some of the Do and whiles and others, but all to no avail.

Thanks,

Ixen

Share this post


Link to post
Share on other sites



well Do / Until and While / Wend and For / Next are all loops, but if you don't post any code we can't tell you what you did wrong not to make it infinite.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

The problem is that I didn't save my mistakes to be able to come back and correct them later and continued to modify the same script over and over. I couldn't get my script to loop at all, but the one thing I didn't try was including the message box (mostly because it will minimize my game when it comes up).

What code would you suggest using for it?

Share this post


Link to post
Share on other sites

However, for RunWAit I used:

RunWait("SWG.exe","C:\Documents and Settings\Greg\Desktop\Coding\MAcros\SWG")

Share this post


Link to post
Share on other sites

in general you can do:

while 1
;here is your code
wend

thats it

It's that easy?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Okay, Thank you.

Here's my script:

while 1
HotKeySet("{ESC}", "Stop")
Sleep ( 5000 )
Sleep ( 2000 )
MouseMove ( 166, 120 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseMove ( 213, 127 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
Sleep ( 5300 )

*Repeat the last sixteen lines 10 more times*

MouseMove ( 166, 120 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseMove ( 213, 127 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
Sleep ( 2000 )
Func Stop()
    Exit 0
EndFunc
wend
Edited by Ixen

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Okay, Thank you.

Here's my script:

while 1
HotKeySet("{ESC}", "Stop")
Sleep ( 5000 )
Sleep ( 2000 )
MouseMove ( 166, 120 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseMove ( 213, 127 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
Sleep ( 5300 )

*Repeat the last sixteen lines 10 more times*

MouseMove ( 166, 120 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseMove ( 213, 127 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
Sleep ( 2000 )
Func Stop()
    Exit 0
EndFunc
wend
the hotkeyset is better if it's outside the loop

why do you use 2 sleeps after another?

you just have to put down your code once

the function needs to be outside the loop as well

HotKeySet("{ESC}", "Stop")
while 1
Sleep ( 7000 )
MouseMove ( 166, 120 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseMove ( 213, 127 )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )
MouseClick ( "left" )

wend
Func Stop()
    Exit 0
EndFunc

this 1 is better

for which game do you need it?

Edited by Nuffilein805

Share this post


Link to post
Share on other sites

I did the two sleeps because it was easier for me to figure out what i need to for time. I'm running this for the game Star Wars Galaxies and using a crafting macro along with it, and this script's success relies totally on my timing and symmetry with the in-game macro.

Share this post


Link to post
Share on other sites

Right now I'm adding an extra command to make it maximize the game and press F1 once it's activated, so that I won't have to worry about maximizing the game and pressing F1 in time for it to work correctly. Once I get that in I'll post back here B)

Share this post


Link to post
Share on other sites

Thank you very much for helping this little coding noob B)

Share this post


Link to post
Share on other sites

Okay, well I finished up my script and the macro along with it but now i have a little problem: it says that my send command for F1 is invalid B) I followed what it said in the help file to include as, and here is what I put:

Send ( "{F1}" [, 0] )

Share this post


Link to post
Share on other sites

Okay, well I finished up my script and the macro along with it but now i have a little problem: it says that my send command for F1 is invalid B) I followed what it said in the help file to include as, and here is what I put:

Send ( "{F1}" [, 0] )
[, 0] means that ,0 is optional:

So it could be:

Send ( "{F1}" )

or

Send ( "{F1}", 0 )

or

Send ( "{F1}", 1 )

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yeah, I reread the help file again and was testing it out and it works perfectly now. Thanks again guys.

BTW, I used:

Send ( "{F1}" )

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