How To Stop a Specific Instance of a Running Macro

Just like entering a hotkey to start a macro, I want to know how to enter a hotkey to stop only certain macros, not all macros.

ex) [shift+a] start the macro, [shift+v] stop this macro. not other macro
ex2) Stop when hotkey is pressed once more

-This sentence has been translated from Korean

You can stop a specific instance of an executing macro with the Cancel a Specific Macro action.

Example 1:

Macro Doit, Trigger Shift-A
Actions:

Macro Cancel Doit, Trigger Shift-V

Example 2:

Macro Doit, Trigger Shift-A

  • If variable DND_Macro Doit is not empty
  • else
    • Do stuff
    • Set variable DND_Macro Doit to text “”

To handle the case where the macro fails or aborts for other reasons and so DND_Macro Doit is not cleared, you could go a little further and validate whether %Variable%DND_Macro Doit%, when it is not empty, is or is not in ExecutingInstances token. But probably this is not necessary, since the only result would be that pressing Shift-A in this case would “cancel” the already not running macro, and then pressing it again would start it.

2 Likes

Thx. I couldn't follow along perfectly, but got a big hint. And succeeded.
Thank you a lot. :smiley:

-This sentence has been translated from Korean

1 Like

can someone please make a downloadable example macro for this? Thanks

Here’s an example. Two macros:

  1. The start macro starts a running instance, pauses three seconds and shows an alert. That bit is just to show you it’s running.
  2. The cancel macro cancels that other one and deletes the variable used to record the macro’s instance UUID.

Download Macro(s): DEMO- Start specific macro instance.kmmacros (2.8 KB)

Download Macro(s): DEMO- Cancel specific macro instance.kmmacros (2.1 KB)

Macro Screenshots (click to expand/collapse)


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.5.1
  • Keyboard Maestro v10.2