Standardizing Common Shortcuts

I like making unordered lists in my writing, but not every app or web-based editor has the same keyboard shortcut to start a list.

This macro uses a boatload of If Then blocks to make sure that any place I might want to make an unordered list, I can use ⌘⇧U.

Concern: Is this bad practice? Like, will this cause performance issue. Should I have individual macros for each case?

Universal Unordered List Shortcut.kmmacros (7.2 KB)

Generally in cases like this, I find Switch or Case action (KM Wiki) to be a better choice.

I've used both methods (one long macro vs a separate macro for each app), and the both have their uses.

For example, if you have a number of apps that all use the same shortcut, then having one macro makes sense to me. I would put that behavior in the otherwise case (at the end) of the Switch action.

I don't think there is any material difference in performance. It mostly comes down to:

  1. Which is easier to write
  2. Which is easier to maintain

Or, as we like to say in Texas: "Six one -- half-a-dozen the other." :wink:

1 Like

Switch wouldn’t work well since @tomslug is basing it on both application and window conditions.

The down side of either this or the switch method is that the Command-Shift-U keystroke it swallowed everywhere (unless you put the macro in a macro group that is restricted to only the specified applications, which would be a duplication likely to confuse when you add support for another application).

An alternative method is to have a macro group for each context (application or window) and put a macro in each, which then needs no conditionals. However now you have the macro and trigger defined in each macro group, so it has its own drawbacks.

Which is better is not really clear, so whatever works and solves your problem and doesn’t cause other problems is the “best” solution. And then when you do hit a problem, then you need to look again and see what solution to choose.

1 Like

Hmmm, I don't know. Mostly the decisions are based on App, or could be based on app, like the "Google Docs" and "Keyboard Maestro" windows. Obviously both use a browser.

So, if, in fact, most decisions are based on app, or could be, then setup a Switch based on App Name, and then, if needed, add a If/Then (or another sub-Switch) to deal with windows, etc.

In fact, count them Peter -- only one case where an App is NOT used, so again, it could be.

So, I'll have to disagree. I think a primary Switch based on App would work very well. You just need proper design. :wink:

1 Like

That's a good point. At current I don't know that any actions in my daily apps are mapped to that combination, but if it does come up, I've written a note to my self to sequester this macro in it's own group. I think having one macro group containing one macro is still better than having 5+ macros in their respective app-specific macro groups.

@JMichaelTX , I was confused at first about how exactly I would use a Switch to check for app, but then I read your ACTION: Switch Case Based on FrontMost App that taught me about the %Application%1% token. I confess I didn't know about those!

I think I'm going to use a block of If/Then/Else for the web-based editors and a block for apps using a switch. Mainly I'm keeping it mixed so I'll remember what you can do with switches and tokens.

Thanks for the help and friendly debate :wink:

1 Like

I think I've found an adequate solution. I made an Otherwise statment executes Keystroke ⇧⌘U. So if there's no conditions met, it just goes ahead and types the combination the app excecute whatever nataive shortcuts is set to that combo. Ex. Evernote

This is how I've been doing it. When I get a new app that needs a remapped hotkey, I just make a new macro group. Inevitably I will make other macros for that app anyway.

For this particular case I like this universal shortcut solution, but I have lot's of app-specific macros too.

Try this trick for keeping all those groups together: prepend similar group names with a similar symbol. I use Ω so my app-specific macros will always be at the top.