How to break in the middle of a macro

I know, I know… sound like a dumb question but I couldn’t find the way to end a macro in the middle in case something goes wrong.

So, is there a way to stop a macro in the middle of a “catastrophic” loop ?

Thanks

You mean manually, or automatically?

Manually, you can use the Cancel menu of KM’s Status menu, or you can use the Cancel All Macros action (from the Keyboard Maestro category).

Automatically, you could use a variable to count the number of loops. Or you could use the Breakpoint This Macro action in your loop while debugging the macro.

For catastrophic failures, you can hold all the modifiers down (Command, Control, Option, Shift) and click the status menu, that will cancel all running macros.

You can also use the Cancel This Macro action to stop the macro in the middle.

Thanks for your time and reply

Well… I missed an important details. All the macros run with 0.7 or 1 second pause. Kind repetitive:
{loop for 250 time}mouse here click, mouse here click, mouse here{/loop}
I got no time to move the cursor and go in any menu (hu hu hu) but if something goes wrong it’s a pain…

"You can also use the Cancel This Macro action to stop the macro in the middle.”
Can I activate this by pressing a key with a loop ?


Self-answer:
I set a “if then else” command (if key pressed then) with “break from loop” within my loop got get a safe exit in case of.

Thanks Philippe and Peter for helping my braincells today. :slight_smile:

I’ve had similar issues so I created a macro that cancels all macros connected to a hot key.

1 Like

I also have a macro to cancel all other macros.

It looks like this:

2 Likes

When I try to use the Cancel This Macro action, it doesn’t cancel the currently running macro. Maybe I’m using it incorrectly. It cancels from the menu bar, but it won’t cancel when I run the action.

Cancel This Macro will cancel the current macro, including all parts since it was triggered (eg if you use it within an Execute Macro action, it will cancel this macro and the parent). This is generally equivalent to selecting Cancel from the Keyboard Maestro status menu’s Cancel menu.

Cancel Just This Macro will cancel only the macro that it is within (so if you use it within an Execute Macro action, it will cancel this macro and return and continue the parent macro after the Execute Macro action.

Make sure your Cancel This Macro action is actually running, because it certainly appears to work for me.

1 Like