Open App in Background

How can I open an app in the background (i.e. so that it launches but doesn't come to the front and steal focus). I seem to recall that using open -g /Applications/SomeApp.app was effective, but that doesn't seem to work any longer (I'm on OSX 11.6).

This will achieve that:

image

Thanks. Not quite a true background launch, but a good workaround :slightly_smiling_face:

Yes, it switches focus for a moment. So, it achieves the end result but could be annoying if the other App took some time to open. But would work fine for Apps like Finder or Calendar.

When you say that command "doesn't work", do you mean it generates an error, or doesn't do anything, or does something that you don't want? I never knew about "open -g" and I'd like to try it myself.

That's despicable... Please take the time to complain to Apple.

Feedback - macOS - Apple

You should be able to use AppleScript and do something like this:

tell application "Calculator"
   if not running then run
end tell

-Chris

6 Likes

Perfect, thanks so much Chris!

1 Like

No error, it just doesn't work. Putting the -g flag used to launch the app in the background, but it no longer seems to have any effect. It does still open the open without it taking focus, but not purely in the background - wonder if it's just a bug? I've reported it to Apple anyhow.

1 Like

What does the man page say in the Terminal?

Is the -g flag still supposed to be available?

Yes, the man page shows -g as being available:

-g Do not bring the application to the foreground.

Thanks. Sounds like a bug then.

@ccstone's solution works great except for Google Chrome. I've been trying to find a way around it for the past 15 minutes to no avail.
Folks at macos - Open a web page in Google Chrome without activating it - Ask Different claim it may not be achievable at all with Apple Script due to Chrome's lack of compliance with the AS standard.

I've tried open -jga "Google Chrome" but it didn't work. Any ideas?

EDIT:
I've messed with Keyboard Maestro's macros

but it's far from what I'm trying to achieve (since the window would blink briefly for obvious reasons)