Jump to content

Need Help with Looping


Ixen
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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)

Link to comment
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] )
Link to comment
Share on other sites

  • Developers

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 )

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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