Simple application launcher with hotkey

Hi there!

I’m new to KM (and Mac actually) and am still trying to figure out how things work.
What I’m trying to achieve is to create simple hotkeys to launch applications. I want the hotkey to open a new window of the application no matter if it was already running or not. I also don’t want it to activate an already open window of that application (and even take me to a different space).
I managed to achieve this for Finder and Safari by opening/activating the app and sending a CMD+N to it. I was lucky and stumbled across an apple script for KM that achieves the same for iTerm2.

However, how would I proceed for Applications like Calculator where CMD+N is not available?

Thanks in advance for your help!

Hey There,

You can’t open a new window in Calculator - period. Nor can you launch another instance of it.

OSX does not have a public API for Spaces, so KM does not control them. (Complain to Apple.)

Basically you’ll need to tinker to get as close as possible to what you want.

In some instances AppleScript will be your best option, but not all apps are scriptable.

An example:

set winTarget to path to documents folder
tell application "Finder"
  set newFinderWin to make new Finder window
  tell newFinderWin
    set target to winTarget
    set bounds to {0, 44, 870, 520} # Size & Screen Location.
  end tell
end tell

Best Regards,

I find it hard to believe that it should be really not possible.
And it certainly is possible to launch more than one instance. I can launch for example multiple calculator instances by running
/Applications/ &
multiple times. So is there a way in KM to run terminal commands without KM opening a terminal window?

Edit: OK, running scripts is easy enough, I’m still struggling to give the newly opened Calculator window (via shell script) focus and bring it to the front. ‘Activate Application’ and ‘Bring Application Windows to Front’ does not show the (at least from me) expected behaviour…

Yes, you can use the Execute Shell Script action to execute a script. No need to the &, just tell the action to execute asynchronously.

And yes, you can open more than one copy of Calculator (or any application) this way, but also note that applications on the Mac are generally not written to support that (with few exceptions). Some applications will accidentally have no issues with this (Calculator probably falls into this category), other applications would fail badly (the Keyboard Maestro editor for example).

Also, as you’re finding out, having a single application open multiple times introduces all sorts of problems with how to talk to it.

The Mac basically does not work this way - one application has at most one running instance.

OK. Thank you for your help!
Still, even if I only open one instance through script, I can’t get it to open as active and top most window. This is not an issue if I use the ‘Open’ Macro. Any reason for that? I’m just being curious.

Thanks again for your help. Still trying to get accustomed to how things work on a Mac. It’s hard to break old habits :grin:

How are you opening which application that is not becoming the top most window?

For Calculator, you can use Activate Specific Application PCalcCalculator, or Execute Shell Script “open PCalcCalculator” or a number of other options.

It just happens when I open Calculator with


through ‘Execute a Shell Script’. If I choose the ‘Open a File, Folder or Application’ Macro, Calculator opens as expected as the top most window.
Note that when I opened it through shell script, even an ‘Activate Specific Application’ does not focus the app…

Not really a problem at this point, I just don’t know why it wouldn’t work.

As a general rule you should not open Mac applications like that. Use


Opening them by running the binary directly does not behave in quite the same way (as you have discovered).