Jump to content
Macro Express Forums
Sign in to follow this  
solaris1985

Repeating A Macro

Recommended Posts

Hi I just made a macro -- however I need this macro to run over night, I used the quick wizard and set up a mouse movement and keystroke recording macro but I have no idea how to make it repeat all night, I also need to know how to stop the macro in the morning -- can anyone help please?

Share this post


Link to post
Share on other sites

I don't know if this is the best way, but this is how I've done it in the past.

 

Use whatever variable names you want, I'll use N1 for the example. You will need to set your computer to military time for this to work BTW.

 

- Set variable N1 to the current hour.

- Repeat while N1 > 8.

...have your macro run and run again

...set N1 to current hour again at the end, but inside the end repeat.

- End Repeat

 

So, you would start the macro at 16:00, N1 would be 16. the next hour it would be 17. once it got to 1am, it would be set to 1, 2am = 2, all the way until N1 hits 8am = 8.

 

The macro would stop.

 

HTH

Share this post


Link to post
Share on other sites

Well there are other ways to do it, but we need more info about what you are having the macro do.

 

If you need the macro to repeat only 50 times overnight, put that into a Repeat statement with pauses at the end of every macro run, and increment your counter.

Share this post


Link to post
Share on other sites

If you want to manually stop it in the morning, then thats easy.

 

Just use a general repeat function. Repeat until N1 = 0, and at the end of the macro set N1 = 1. That way it will never hit zero.

 

Then in the morning, right click the little running man icon in the task bar. That will stop the macro.

Share this post


Link to post
Share on other sites

I'm sorry I'm asking super shallow questions but what is N1? Is it a command I put in the macros script or something? Please, talk to me like a total noob! Also, when the macro is repeaditly moving my mouse it is difficult to right click on the icon, is there something I can do to manually stop it on the keyboard?

Share this post


Link to post
Share on other sites

This sample macro may give you a starting point:

Repeat Until %N1% <> %N1%
 Mouse Move Position 10, 10
Repeat End

Oops. This originally said %N1%=%N1%. The example has been corrected.

 

There are two ways to terminate a running macro. You can click on the running man icon in the system tray or you can press the Scroll Lock and Pause keys at the same time.

 

Note that the 'Abort Macro HotKey' may be set to something else in the preferences. Check the 'Abort Macro HotKey' setting in Options, Preferences, Playback.

Edited by kevin

Share this post


Link to post
Share on other sites

The Repeat End function makes the macro stop repeating, completely defeats the entire purpose of putting it in the first place, I simply want the macro to keep going and going for days untill I stop it.. What do I put?

Share this post


Link to post
Share on other sites
If you want to manually stop it in the morning, then thats easy.

 

Just use a general repeat function. Repeat until N1 = 0, and at the end of the macro set N1 = 1. That way it will never hit zero.

 

Then in the morning, right click the little running man icon in the task bar. That will stop the macro.

What do you mean but set "N1 = 1" -- I have no idea who to set this... I figured out how to do Repeat Until %N1% = 0 but putting End Repeat at the end of the macro just stops it... Is there any way to make a macro contriniously go???

Share this post


Link to post
Share on other sites
The Repeat End function makes the macro stop repeating, completely defeats the entire purpose of putting it in the first place, I simply want the macro to keep going and going for days untill I stop it.. What do I put?

Repeat End merely specifies the end of the loop to be repeated. When the macro encounters the repeat end command, it jumps back up to the line after the initial Repeat statement (if the conditions for terminating the loop have not been satisfied yet).

 

%N1% is an integer variable. It holds any integer within the macro, hence setting it to = 1 means any time you ask for the value of %N1% you get back 1.

 

The macro will continue to repeat since %N1% will never = 0, therefore the repeat loop will not terminate until you manually break out of the macro.

Share this post


Link to post
Share on other sites

The repeat loop will continue until the variable N1 is not equal to the variable N1. Since this can never occur, the repeat continues forever, thus requiring something else to stop the macro. The Repeat End does not tell the repeat loop to end, it shows where the loop will end when the condition specified by the Repeat Until command is satisfied. This is essentially the same thing as repeating until N1 = 0 and setting N1 to 1 at the bottom of the loop as suggested by polishmafia.

 

To understand variables read the Variables Overview topic in the help. You can access this by clicking Help, Macro Express Help from within Macro Express. Then click on the Search tab and type 'variables overview' as a search term. Or, you can view the Variables Overview online. Note that this link to the online help may change (i.e. break) in the future.

 

Often the best way to understand a technique is to try it. Create a new macro, enter these macro commands and run it.

Repeat Until %N1% <> %N1%
 Mouse Move Position 10, 10
 Delay 2
 Sound Beep
Repeat End

As this macro runs it will beep every two seconds and the mouse will move until it runs out of places to move. You will have to press Scroll Lock+Pause or click your mouse on the running man icon in the system tray to stop the macro.

Edited by kevin

Share this post


Link to post
Share on other sites
This sample macro may give you a starting point:
Repeat Until %N1% = %N1%
 Mouse Move Position 10, 10
Repeat End

Wouldn't %N1% ALWAYS = %N1%? I think you meant to check it against something else (a constant?), otherwise that loop would not work.

 

EDIT: I think you meant Repeat Until %N1% <> %N1%

Share this post


Link to post
Share on other sites
Wouldn't %N1% ALWAYS = %N1%? I think you meant to check it against something else (a constant?), otherwise that loop would not work.
Oops. Yes, this should be %N1% <> %N1%. Thanks for pointing that out. I've edited the last post to fix this.

 

There are several ways to stop the macro in the middle of a repeat loop that loops forever in addition to the 'Abort Macro HotKey' and clicking on the icon in the system tray mentioned earlier. This example shows two ways to stop the repeat loop inside the macro itself.

Repeat Until %N1% <> %N1%

  Sound Beep

  If <some condition>

    Macro Stop

  End If

  If <some other condition>

    Break

  End If

  Delay 2

Repeat End

The Macro Stop command will stop the macro entirely. The Break command will stop the repeat loop and allow the macro to continue. The 'If <some condition>' and 'If <some other condition>' can be a variable set a specific way, the existence of a file, or a window popping up.

Edited by kevin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...