Can a Plug-In Action find out the name of the executing macro?

I have a plug-in action that displays text in BBEdit, passing the text via a $KMPARAM_ variable. I would like the BBEdit file to also show the name of the macro from which the plug-in action was executed. Of course, I could pass the macro name as part of the variable every time I use the action, but I'd like to build it into the macro itself so I don't have to remember to do it. I can't see a way to do this, but I thought someone else might.

1 Like

Here's an untested idea: You might take a look at this KM token:
ExecutingMacro token

do shell script "echo $KMPARAM_ExecutingMacro" doesn't output anything.

I used the env command to output a list of environment variables (as Peter suggests here) and couldn’t find anything with the name of the executing macro, so I have to assume that information isn't available to plug-in actions.

Peter, here's a feature request: It would be great if plug-in actions were able to parse KM tokens. Failing that, it would be helpful if details of the executing macro could be passed in an environment variable.

A Token is not a Keyboard Maestro variable nor is it a Plug In Action parameter, so it wont be in the environment variables.

You would need to save the ExecutingMacro token into a variable, and then you could access it via the $KMVAR_Variable_Name environment variable.

You can parse tokens via AppleScript to the Keyboard Maestro Engine, but that likely wont get you this kind of instance-specific information.