Sign in to follow this  
Followers 0
Ravel

Stop a recursive macro

5 posts in this topic

I am not completely familier with all of the autoit script commands, and how to get them to work together, but I have a script here that I would like to repeat indefinitly until I press a Hot key such as ESC. Can you all review the script below and tell me what is wrong... right now it just states that the first line is not a valid command. Thanks.

HotKeySet("{ESC}", "Terminate")

WinWaitActive, SimCity 4

Sleep, 100

start:

WinActivate, SimCity 4

Send, ^x

Sleep, 100

Send, weaknesspays {ENTER}

Sleep, 100

goto, start

Func Terminate()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the forums!

Some of this script is in AutoIt v2 syntax. This should do it for you:

HotkeySet('{ESC}', 'Terminate')
WinWaitActive('SimCity 4')

While 1
    WinActivate('SimCity 4')
    Send('^x')
    Sleep(100)
    Send('weaknesspays{ENTER}')
    Sleep(100)
WEnd

Func Terminate()
    Exit
EndFunc

Edit: Note that this script needs AutoIt v3 to run. While 1..WEnd invokes an infinite loop, broken by the Terminate() function when you press ESC.

Edited by LxP

Share this post


Link to post
Share on other sites

Welcome to the forums!

Some of this script is in AutoIt v2 syntax. This should do it for you:

HotkeySet('{ESC}', 'Terminate')
WinWaitActive('SimCity 4')

While 1
    WinActivate('SimCity 4')
    Send('^x')
    Sleep(100)
    Send('weaknesspays{ENTER}')
    Sleep(100)
WEnd

Func Terminate()
    Exit
EndFunc

Edit: Note that this script needs AutoIt v3. to run. While 1..WEnd invokes an infinite loop, broken by the Terminate() function when you press ESC.

Ok thanks. Would this work in version 3? I just downloaded it because I noticed that I was in the v3 forum.

Share this post


Link to post
Share on other sites

Yes, the script is written for AutoIt v3. What I meant by my initial remark was that your script was partially written in v2 and v3 syntax which is why it wasn't working for you.

If you are new to learning AutoIt then v3 is a better choice anyway since it has a more standardised syntax, tidier code and better possibilities.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes, the script is written for AutoIt v3. What I meant by my initial remark was that your script was partially written in v2 and v3 syntax which is why it wasn't working for you.

If you are new to learning AutoIt then v3 is a better choice anyway since it has a more standardised syntax, tidier code and better possibilities.

That did it...THANKS!!! I had a time trying to figure out what was going wrong. Oh yea thanks for having me on the boards. Glad to be apart of them.

Edited by Ravel

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