Add Action to Macros in Bulk

Hi, I want to take a group of simple text expansion macros and add the same action to each (moving cursor to the start of the replaced text). Is there a way to select all the relevant macros and apply that change in bulk? Tried to highlight a group and then insert an action via the edit menu but those commands aren't active.

Hey @sottovoce,

Keyboard Maestro doesn't support bulk editing.

The job can be done, but it requires AppleScript and is a bit complicated.

Usually when I do this sort of thing I build a Keyboard Maestro macro to do the job.

It's a bit clunky, but it's waay faster than doing things by hand if there are very many macros to edit.

-Chris

Thank you for the suggestion. For now, a macro sounds like the easiest way to do this.

1 Like

Does anyone have an example macro to edit an action within another KM macro? E.g., I want a macro that will edit the text within another macro in the same way. For instance, the text tag "[text]" -- I want to replace with "[###text]". The tag "[more text]" woudl become [###more text], etc.

I wasn't able to do this using "record macro"-- if I hit record and then go into the KM macro I want to edit, the recording is stopped.

Hey @sottovoce,

I'd need to see an actual example of what you're working with.

-Chris

If you just want to add the SAME action to several macros, I'd suggest create it apart, and then call it with a "Execute Macro".

1.- Create a macro with the action, say "Paste", name it "Paste"
2.- Go to one of the other macros where you want to add the macro you just created.
3.- Add an "Execute Macro" action
image
4.- In the dropdown, select the one named "Paste"
image
5.- You can copy this "Execute Macro" to the other ones.

Hi, I think my explanation wasn't clear so let me try again: I'm trying to create a macro that will go into another macro, one that I've selected from the macros list, and edit that selected macro's action. The action I'm trying to edit is "Insert Text by typing". The ideal workflow:

  1. I create a macro called "add ### to KM macro text"
  2. go to a KM macro, lets say "print HELLO" which just outputs "HELLO"
  3. invoke the "add ### to KM macro text" with a keyboard shortcut
  4. It edits "print HELLO" so that the output is "### HELLO" (prefaced with the hash marks)
  5. use arrow down key to move to the next macro in the grouping, e.g. "WORLD"
  6. repeat step 3

My problem is with step 3: how do I record a macro that does that? That macro goes into the active macro I'm on, edits the action "inserts text by typing". But I've not found a way to create that-- "record macro" stops if you start interacting with another KM macro.

The truth is that I'm tying myself in knots to do bulk editing b/c I was told this isn't supported.

While there are some use cases where you might need to change the actual KM Action settings, most use cases can be satisfied by using KM Variables, Tokens, and/or Functions. Using these do NOT require that the actual Action settings be changed:

So, if you have this Action:

image

You can easily change what is typed by setting the KM Variable TextToBeTyped by another Macro before the Macro which contains that Action is triggered.

Make sense?

If you truly have an use case that requires the Action settings to be changed, you will need to use AppleScript to get the Action XML, change that XML, and update the Action with the revised XML.

Thank you for the explanation. I'll make sure to use variables in the future for configurability. But for this situation, it sounds like I'll have to add in that variable or text string for each text expansion macro which I was hoping to avoid.