How to prevent a timed macro from executing twice at the same time?

I have a macro that pops up a dialog box every 15 minutes. I’d like to set the macro to not run again if the dialog is present. I’ve tried setting a “dialog is active” type variable, but it’s a complex macro and there’s ways to cancel it out that seem to prevent it from having the opportunity to reset that variable.

Is there any way to put an “if” condition to test whether the macro in question is actively running?

Can you not use the semaphore lock/unlock actions?

lock at the start, unlock at the end.

1 Like

The challenge is that the macro generates dialogs at various points and it
seems that it’s easily cancelled so it never gets to the end.

I stand corrected, the semaphore unlock seems to work here since it unlocks at the end of macro execution.

Never used that action before, thanks @cluttered!

Follow-up question… When I use Semaphore Lock, it properly prevents multiple executions of the macro, but when I unlock the semaphore, the macro “catches up” on missed actions. For a frequent timed macro, this can result in my having a stream of new dialogs created and I have to dismiss all of them. Any ideas on how to prevent this from happening?

Not seen this so I can’t really say.
One thought maybe, at the end, just before the last step (the unlock), do a ‘cancel this macro’, if that just cancels the one instance then it won’t help, but if it cancels all instances of that one macro then it might work?
There’s a ‘cancel this macro’ and a ‘cancel just this macro’, so maybe the first one would cancel all instances of the one macro and the second just a single instance? Just looked in the manual and it doesn’t seem to discuss these. Worth a try.

Good idea, but unfortunately it doesn’t work. I ended up adding a last execution variable and just exiting the macro if it’s too short a time.

You could use Cancel All Macros at the end of your macro.

Or for most cases, you could set a very short timeout on the Semaphore Lock, and include a Pause in the macro before (implicitly or explicitly) unlocking it at the end - you’ll still get a repeat of any very recently triggered macros.