Create group action encompassing selected actions?

There’s one situation where it puts the group in the wrong place (off by 1) - can’t remember whether it’s when the actions are at the beginning or end. But just move it when that happens.

It happens when all of the selected Actions are at the TOP of the macro.
I’m sure there must be a fix for this, I just haven’t gotten around to figuring it out. Any ideas?

No, I’ve thought about it, many times, every now and then. I kept thinking my brain would surface an idea, but it never does.

Honestly, it only happens in that specific instance, and I can live with it.

I should look at the status sometime and see how often. I wonder which of these kinds of macros I use the most? Dammit, now I’m sidetracked again!

Similarly, I wrote a few trivial macros for the KM Editor that insert actions I use frequently above and below the current selection:

Action Keybinding toInsert Below Keybinding toInsert Above
Comment ⌥⌘C ⌥⇧⌘C
Group ⌥⌘G ⌥⇧⌘G
Keystroke ⌥⌘K ⌥⇧⌘K

and so on.

These macros are very simple. The ones that insert above do so simply by beginning with an uparrow keystroke. This of course doesn’t work if the top macro is part of the selection. I haven’t found a way to hack around this.I haven’t found a simple way to make any of the “above” versions of the “before” version of these to insert before the top action.

[Side note about tables. Discourse formatting does not support tables. (See 2.5 year unresolved discussion at Discourse Meta. But it does support (at least) very primitive HTML. Very primitive. I couldn’t even get the first heading cell to be top-aligned, and a br tag within one of the header cells worked in the preview but not in the actual post.]

All of those, except the Group Macro (which I previously published), can be replaced with @DanThomas' great KMFAM system:

I highly recommend Dan's KMFAM system.

Thanks. I’ll take a look. But does this include inserting above the current selection? I find that very useful.

If you are referring to my macro, yes, it inserts the Group above the selected Actions.

If you are referring to Dan’s system, it inserts below the currently selected Action, just like KM does natively. Obviously, if you want it above, then select the above Action prior to triggering the macro.

I wish there was a foolproof way of controlling (via automation) where something gets inserted in the KM Editor but there isn’t. Even JM’s Group macro (which I highly recommend) doesn’t always insert the group in the correct position, although it does 95% of the time.

Perhaps someday Peter will give us more control, but until then, we take what we’ve got. :slight_smile:

Hey Mitchell,

No hacking required.

Try “Paste Above” ( V )


1 Like

Awesome! Any idea why it’s not in the menu?

I don’t understand what you are referring to — take the simplest possible example: insert Simulate a Keystroke above the currently selected action(s). And is Paste Above — whatever it is — able to paste above the first action?

Hey Dan,

It is in the menu. Search for “paste” or “above” in the search field of the Help menu.

Or go the the “Edit” menu and hold down the key.


1 Like

Hey Mitchell,

I see – you're just inserting actions by giving them keyboard shortcuts.

No there's currently no built-in insert above capability in the Keyboard Maestro editor.

You'd have to roll-your-own by saving a template to a variable, named-clipboard, or file and then copying it to the clipboard as the appropriate data-type and then pasting-before.

Or you could write a macro to:

  1. Insert action(s)
  • Cut
  • Up-Arrow (or more depending upon what type of action)
  • Paste-Above

The former takes more effort to set-up but feels more organic and lets you set up templates the way you want them. (For instance I nearly always want the Display Text to display in a window.)

The latter is a trifle clunky, but it works well.

Insert Display Text Action → Above Selected Action.kmmacros (3.9 KB)


Actually, I believe it works all the time, except when you include the top Action in the Actions to be put into the Group.

Does anyone know how to determine if the selected Actions include the top action?
If so, we can use the ⌘⌥V to do the paste in that case.

All that seems more trouble than it’s worth, when you can just manually arrow up one Action and then insert the new Action.

But if you must automate it, then it could be done simply by:

  1. Type Keystroke [UP ARROW]
  2. Menu Edit > Insert Action by Name

Yes, but that doesn’t handle Mitchell’s case of the FIRST action.


Presently you'd have to do something like Search for Image:

I only search for images when there's no other way, because it's a bit slow.


Yep. There is always a decision to be make when considering automation:

Cost of automation vs:

  • Frequency of use
  • Changing workflow

In this case, dealing with adding an action to to the top of a Macro, I submit that:

  • Best practice, IMO, is to always have a Comment action at the top that provides the Release Notes (except for quick-and-dirty tests).
  • So I automatically add a Comment Action (now using @DanThomas’ powerful KM FAM) when I create new macros.
  • Even better, is to create a new macro from my favorites that includes the Comment Action, using @DanThomas’ KMFAM
  • Most insert Actions will be below the top Action
  • Even if you need it to be at the top, it is very easy to drag/drop it to the top.

So, for me, I’m not going to spend/waste any time on automating insertion at the top of the Macro.

This is a good idea. In fact, I have a small macro that creates a new macro, adds a keystroke trigger, and selects the macro name field. It would be trivial, and a good idea, to include inserting a comment in that macro.

I’m not concerned about inserting above the first action, though it is often a slight annoyance (any special case is). I was just commenting originally that inserting before the first action is problematic — didn’t mean this to blow up.