Cancel All Macros, Except "This One"

I have a shortcut that cancels all macros.

Now I have this macro that backups my Notes app and I want to let it run until it completes the backup.

Can I have a shortcut that cancels all other macros, but excludes 1 or more macros?

Are you looking for this?

...or do you want to prevent other macros running for the duration of your backup macro?

So when I use that shortcut, it cancels ALL running macros, except for some that I find useful to keep running, such as the Notes backup, for example

In which case, you probably mean disable, not cancel.

I think I really mean cancel. Here's an example:
Let's say I just started the macro that backups up my Notes. Since I have a lot of notes, it takes a few minutes. Meanwhile, I'm testing other macros and sometimes, when bugs occur, one macro doesn't stop running and then when I test it again, it seems that it creates 2 instances (or more) of that macro. So I use that shortcut to completely cancel all macros.
In this case, if I have 10 macros running, including the backup, I want 9 to completely stop running (cancel) and leave the backups macro running.

I just checked and you can't select the All Macros Smart Group, so the only thing I can think of is to separately disable each macro group. However, I see that @Zabobon is typing, so I expect to be corrected!

Using this action:

can't we use those "strings" you shared yesterday?
a: (for all) and then use the - to exclude a particular macro?
Hope it makes sense

No, you can't do that. The best you could do is have your "kill all but some" Macro cancel "All Other Macros" and then have it start the Macros again that you want running. (But I wouldn't recommend this - especially cancelling a backup Macro that is half-way through.)

Okay, I found this:


No, the way this works is:

You'd set a variable at the start of a macro that you do want to cancel, like so:

This can then be referenced like this:

Unfortunately Sleepy doesn't provide any example macros...

token:ExecutingInstances [Keyboard Maestro Wiki]

The %ExecutingInstances% token returns instance UUIDs from all running macros.

So – your notes macro would need to have saved out its instance UUID for later removal from the instance list.

Ok then I guess my best option for now, since I don't want to cancel that specific macro by accident, is to have this:


The problem with that is that if you have a rogue test macro that is doing damage and your Backup Notes Macro is running, the rogue Macro will continue running...

I think safer to just have a "Kill All" Macro that you only fire when things are going wrong and accept that everything gets cancelled.

1 Like

I see what you mean. Yeah maybe I can have 2 macros:

  • The one I have now
  • One called PANIC that cancels all of them, no matter what, with a different shortcut

Maybe @peternlewis could consider this on a future update...?

That would allow us to keep important macros running, especially macros that take longer to complete, while killing problematic ones.

This is a MUST HAVE macro!

Mine has saved me from hosing my entire hard drive at least twice – and from various other mayhem a few times.

I wrote it many years ago after creating a macro that failed to terminate as expected and commandeered my mouse and keyboard completely. I had to force shut-down my Mac and was a less then happy camper.

You can already do this with a little work. Did you read post #11?

I would look at this situation the other way around. When the backup Macro is running, that is the time to take a break and get a coffee, not the time to be testing other Macros. So, I would make use of KM's Progress Bar to let me know that the backup Macro is running and give me an indication of how it is doing.


How would you cancel multiple macros using their UUIDs? Can you use one Cancel a Specific Macro action? If so, you could set a variable at the start of the backup macro like this:

Then, the cancel macro would look like this:

Cancel All Macros except DontCancel.kmmacros (20 KB)

Macro screenshot

This probably doesn't work, but maybe there's an AppleScript that will cancel each UUID in the list...?

AFAIK you can only get a macro's name or UUID from inside that macro. What should probably work though is your macro above but with the final action replaced with a "For Each", using "Lines in Local__RunningMacros" and "Cancel a Specific Instance".

That may not be doing what you want -- remember that "is active" is not the same as "is executing"!

Edit to Add
Proof of concept. A macros called "To Stay Open" that will not be cancelled, "To Be Cancelled" which will, "Launcher" to fire up one instance of "To Stay Open" and 10 of "To Be Cancelled", and "Cancel All But..." to do the dirty work.

Fire off "Launcher" and check the "Cancel" sub-menu in the KM menu bar icon menu and you'll see all the macros running. Run "Cancel All But..." and check the "Cancel" sub-menu again, and only "To Stay Open" remains running.

Cancel All But....kmmacros (3.3 KB)