1

In Keyboard Maestro I want to create a list of keyboard shortcuts, and then under each keyboard shortcut an action to be performed on a per-app basis if that application is active.

For example, when I press Left, I always want to switch to the tab to the left.

I want this action to apply in Chrome, Safari, Xcode, and other apps. The actions in each app may have different menu bar item names, but I want to save them as a single Keyboard Maestro macro for easier grouping.

The Select or Show a Menu Item action menu item titles I need to activate are:

  • Chrome: "Select Previous Tab"
  • Safari: "Show Previous Tab"

Keyboard Maestro window

But when I set up Keyboard Maestro as seen in the screenshot, this activates all of the actions. Regardless of which app is active, both Chrome and Safari run that action.

How can I set it so that only the active application performs the action, and give it a list of all possible application/action pairs?

2

A fairly simple solution: if-then-else actions. See this one for Finder: A Keyboard Maestro if-then-else action that only works if Finder is at the front.

If you nest each application-specific action within an If statement that checks whether the relevant app is at the front, it should work.

  • That said, I do something similar, but I keep the different actions within different folders that activate only for the relevant application. That way the within-macro If statement isn't necessary. I assume the macros will run faster that way than if you have a large number of statements to check before Keyboard Maestro acts. – ryanjamurphy Mar 15 at 22:50
  • Yeah, that's too much overhead and manual work to set up if conditions and actions for each. Your folder workflow sounds better. I wonder too if there is a "run first action that completes successfully, then exit" construct. – pkamb Mar 15 at 23:05
  • I wouldn't think so, as I think the macro checks and completes items linearly, top-down. You could put in a Cancel This Macro action at the end of each If check, which would end it at the first one that completed—it would just still have to run down the list until it reached one that worked. – ryanjamurphy Mar 16 at 12:32
1

Keyboard Maestro has an Action Category "Front Browser Control" that can be used to send generic commands to web browsers.

I believe my original question/problem still has value, and this answer does not properly solve it, but I was able to use the following commands to fix my immediate issue with the subtle differences between Safari and Chrome:

Actions:

  • "Previous Front Browser Tab"
  • "Next Front Browser Tab"

Front Browser Control

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .