Repeat question

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Leeber
Newbie
Posts: 2
Joined: Wed Aug 26, 2009 8:17 am

Repeat question

Post by Leeber » Wed Aug 26, 2009 8:23 am

I have just started trying out this macro and I wrote a script that only includes mouse movements and clicks.

I did get the script to work, but I want the script to continuously repeat itself (or a, by me, decided number of times) and I do not understand the repeat function.

Thanks in advance / Leeber

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Aug 26, 2009 9:26 am

If you want to repeat continuously for ever (or until YOU stop the macro) then just use a simple Label and Goto:

Code: Select all

Label>start
..
.. your stuff here
..
Goto>start
Repeat/Until is designed to repeat *until* some condition. E.g. the following will repeat until k is 10:

Code: Select all

Let>k=1
Repeat>k
 .. do something
 Let>k=k+1
Until>k=10
Now, you *could* use a Repeat/Until to loop forever by making sure the condition is never realised:

Code: Select all

Repeat>k
 .. do something
Until>k=10
Since k is never set to 10 that loop would loop ad infinitum but it seems a bit inelegant to me. You could also say something like:

Code: Select all

Let>continue=TRUE
Repeat>continue
..
Until>continue=FALSE
But, you might just as well use a simple Label and Goto.

Hope this helps.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Leeber
Newbie
Posts: 2
Joined: Wed Aug 26, 2009 8:17 am

Post by Leeber » Wed Aug 26, 2009 10:13 am

Thanks, the labeltip worked perfectly. However, I couldn't really get the macro to stop... Is it some hotkey for this or do I have to bind my own?

Thanks in advance

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Aug 26, 2009 10:22 am

Shift-Esc is the default stop key. See Tools/Options. Or you can right click on the flashing tray icon and select Stop, or click Stop on the main window.

Might also help to have a small pause in your loop so that it is not running too tightly:

Label>start
..
..
Wait>0.5
Goto>start
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts