Use a single shortcut to activate an app (might running in other spaces) in the current space

Background: I have two spaces, one is for work and one is for entertaining. They are for different purposes, and it is a common situation where the same app is running in both spaces (for example, a web browser app can have 2 different windows, one is related to work and one to Internet browsing, and they are distributed in different spaces).

What I want to achieve: I like the ability to activate an app quickly by using a single shortcut (by using Keyboard maestro, or Karabiner, or BetterTouchTool, or whatever app you would recommend to me). This single shortcut can achieve several things in different situations:

  1. When the app is not running in any of the space, then the obvious thing is to launch it in the current space

  2. When the app is running and have window(s) open in the other space –

    2.1. But there is no window open in the current space – then open a new window of this app

    2.2. And there is already existing window(s) open in the current space – then resume the existing window(s)

Do you know how can I achieve this effect? I have tried many ways with the aforementioned OS assistant apps, but because they can only tell whether the specific app is running and is at the front (even if it is only running and at the front in the other space), but cannot tell if there is a window open or not in the current space, so I cannot achieve 2.1 and 2.2 both at the same time using a single shortcut.

If I activate the app (similar to clicking on the dock icon but with a shortcut) with window(s) running in the other space, then only 2.2 can be achieved not 2.1. In fact, nothing would happen in the case of 2.1, no popping out any window or switching to the other space or anything, because the system assume that the app is running and it already has its focus on it, while in fact the running window is on the other space so the current space cannot see a thing. You always have to follow with a next move, for example, command + N to create a new window, or just switch to the other space to check whether there is a window open, and it's overall a very jarring experience.

Or, I can always open a new window of the app in the current space using shortcut, but in that case only 2.1 can be achieved not 2.2. It's very useful to resume the existing window(s) where you have already been working on in the current space.

Hopefully I have made my conundrum clear enough. It would be much easier for me to navigate the whole OS if I can find a way to work this out, so thank you for any input!


I only have a partial answer that solves following question: How to assign a single shortcut to activate an app?

This solution will:

  • start the app when it is not running
  • when it is running, bring it to the foreground, meaning that the focus will be set to this app.

This can be achieved without a third party application.

  1. Open Automator and select Quick Action (might be called Service in version of macOS earlier than Mojave)
  2. In the new workflow, search for the action Launch application by searching for it in the name searchbox.
  3. Double tap Launch application, which will be added to workflow pane. enter image description here
  4. Select your application from the dropdown list. By default only applications in /Applications will be selected, so choose other... if needed.
  5. Save the workflow. Name it something sensible like Open MyApp.
  6. Open System Preferences > Keyboard. Click the Shortcuts tab and select Services from the left hand pane.
  7. Under General in the right hand pane, you will find your freshly created workflow. Assign a keyboard shortcut there. enter image description here

Hope this helps.

Tested on Catalina 10.15.4.