MACRO: Group-Degroup toggler

I use the Group and Degroup menu items a lot in Keyboard Maestro. As I'm developing a macro, I group things together once I have that section of the code working, so I can collapse them for easier navigation. But then, inevitably, I need to change things up, so I have to degroup and regroup.

Because the Group menu item is buried in a sub-menu, this is a pain—a real pain using a mouse, and a bit of typing even when navigating the menus via the keyboard.

This macro greatly simplifies the group and degroup process: ⌘G does both by applying some simple logic. Here's how it looks in action:

A gif of the group-degroup macro in action

group-ungroup

And here's the macro:

Download Macro(s): Group Toggler.kmmacros (42 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4.1
  • Keyboard Maestro v11.0.2

There's a comment in the macro that explains how it works, but it's incredibly simple: If a Degroup menu item is enabled, then whatever's selected gets degrouped. If that menu is not enabled, and more than one action is selected, those actions are grouped.

Why more than one action? Because I never create a group with a single action in it. If you do, the macro's read me explains how to enable that behavior—with two quick changes (disable green group, enable magenta group), a group will be created even with only one action selected.

It's a simple macro, but for me it's a huge timesaver. I've been using it for quite a while, but finally took a bit of time to clean it up and make it more robust to share here.

-rob.

7 Likes

Very slick, @griffman. Thanks for sharing.

Well done, sir.

1 Like

Just curious. Did you need to add a semaphore lock, or is that something you do with all your macros?

Refs:
https://wiki.keyboardmaestro.com/action/Semaphore_Lock

I found that if I triggered it again too quickly, I wound up undoing what I just did, or vice-versa. The lock has a short timeout, just long enough so that I can't accidentally trigger it again :).

It should work fine without it, too.

-rob.

2 Likes

And I have have just spent about an hour reading all about semaphores and you have answered my question in less than a minute :slight_smile:

1 Like