Disabled macro still runs

I have a macro that calls other macros using the "Execute Macro" action and for testing I need some of those other macros to not run, so I disabled them (using the big 'X' in the macro definition).

The problem is, they still run anyway when executed.

Is this a bug or something my patchy understanding is missing?

Test_1 Test_2

It looks like a bug to me, but we'll need @peternlewis to confirm.
Peter, I've also noticed (in the past) that if the sub-macro is in a Macro Group that is disabled, it will execute anyway when called from a Execute Macro Action.

Yes, the Execute Macro action can execute a macro even if it is inactive, disabled or in a disabled macro group.

Whether this is a bug or a feature depends on your point of view - enabling is about being able to trigger the macro, but you are explicitly executing the macro, it does not even need a trigger.

The Execute Macro action could fail if the macro was disabled (or inactive), but it does not currently work that way - currently it assumes you know what you are doing and executes it anyway. I would not recommend relying on this, but I also don't know if it will change.

If you want to disable the macro execution, you will need to disable the action instead.

I think it’s rash to ever assume I know what I’m doing!! So, rather than disabling the action - which would be tedious and error-prone as it appears in several places - i’ll just build a test in the macro itself to skip execution when desired.

Thanks for clarifying for me...

Another option would be to create an interim macro that just executes the submacro. Then your macros execute the interim macro. Then you can disable that one action and it would disable all the others.

But you can also just add a Cancel Just This Macro action at the start of the macro and it will just do nothing and then return and continue the calling macro.

I think that is a great idea, and probably the best solution.

@peternlewis, is there any way, by KM token or script, to get the activation status of a running macro?

If there is, or you could add this, it would make it very easy to add a test at the top of every sub-macro that you do NOT want to execute if it is not (active or enabled):

Let's say you add a token "MacroIsActivated", which returns a "YES" or "NO".
Then we could do this:

image

This would have no impact on existing Macro, but allow us to easily prevent a non-active Macro from running.

What do you think?

There is a degree to which this question simply does not make sense.

When Keyboard Maestro runs a macro, it takes a copy of the actions and sets off executing them. So after it is running, the concept of “activation status” (which really applies to triggers, not actions) is meaningless.

There is a Macro condition that determines the enabled or activated state of a macro.

That does the trick nicely! Thank you and to @JMichaelTX for the very helpful ideas and suggestions. Cheers.

Well, the issue is that the macro has, in effect, been "triggered" by the Execute Macro. How is this different from the actual trigger "by AppleScript"? Why shouldn't they behave according to the same rules?

IAC, in the context of this thread, it makes perfect sense, perhaps more so if testing the "enabled" status, like this:

image

It doesn't make any difference how it is triggered, my comment was just that the question as asked, namely “to get the activation status of a running macro” does not make sense. You can get the activation status of a macro, as shown. You cannot get the activation status of a “running macro” because there is no concept of activation status once a macro is running.

And yes, it is somewhat inconsistent that you can trigger a macro with Execute a Macro while it is disabled or inactive, but you cannot trigger a macro via AppleScript while it is disabled or inactive.

It is plausible that I will allow triggering a disabled/inactive from AppleScript, if you specify the macro by UID (so that the macro is clear and explicit). Or alternatively (probably less likely) it is possible that I will make Execute a Macro fail if the macro is inactive. Or it is quite possible I wont change any of these behaviours. I would not recommend relying on any of them one way or the other.

Well that certainly clears things up. :rofl:

Since there are several solutions that would prevent a disabled Sub-Macro from running when called by an Execute Macro, I for one would be very surprised if you made a change to KM that broke every macro that currently will run a disabled sub-macro. You have been very consistent and conservative for many years now. Thanks.

In fact using my above example provides a great deal of flexibility while achieving the desired goal. I can imagine a macro whereby the Sub-Macro is enabled or disabled, and then later the Sub-Macro is called, with its actual execution depending on the prior enablement.

I agree, I don't like breaking changes. On the other hand, it is an almost inviolable rule of Keyboard Maestro that a macro can only run if it is active. And this ability of Execute Macro to violate that rule does not fit with that.

So, as I said, I would recommend that if you intend to execute a macro by any means you ensure that macro is active (ie, the the macro is enabled, that the macro group is enabled, and that the macro group is active). Anything else is unsupported and may break in the future.