Is there a way to prevent applications from stealing focus when they startup on macOS?

There are number of applications that I use that take several seconds( some take 10 seconds or more !), to open, or , since I have multiple displays, one I want to open in the left display while I am typing in the application in the right display, perhaps for reference.

However, each application steals focus from the application I’m using when it starts, which interrupts my work. Is there a way to prevent this behavior on a global ( all applications, all displays, all spaces ) level?

I did some research online and found many instances of people asking this question, but not a single solution. I did discover a few people who said that macOS once upon a time did allow applications open without stealing focus, but that was pre-2011.

So, is there a way via system preferences, command line utilities, or 3rd party applications, to tell macOS “hey, I’m working over here, don’t automatically switch me to another application!” ?

Environment:
macOS: 11.5
Dual Thunderbolt display
Each display has it’s own spaces.

1 Like

The last reply in this thread might help:

https://discussions.apple.com/thread/3882355

2 Likes

Short Answer: Yes*

Longer Answer: Yes…if the app is built by a Mac developer who knows what they are doing.

You might have to turn OFF the auto-launch setting in the app itself and app it in:

System Preferences » Users & Groups » Logins Items

The + in the blue box will let you add apps.

The ‘Hide’ checkboxes in the red oval tell the app to NOT steal focus.

Will this work?

It should.

If it doesn’t, you can complain to the developer.

1 Like

Is the requirement that apps need to be hidden (silent in the background) when the launch at macOS boot time?

Or is the requirement that when an app is launched at any other time that it is silent and does not have the focus?

Beside the Login Items under Users & Groups you might want to check the Library > Startup Items

1 Like

You can probably test whether your app of choice is going to respect that “Hide” flag or not by using the terminal.

Launch the App Completely Hidden

open -j -a TextEdit

Launch the App Visible, But in the Background

open -g -a TextEdit

Replace TextEdit with your app of choice.

If there are spaces is in the app name, put “straight quotes” around it. For example:

open -g -a 'Activity Monitor'
4 Likes

I have the same requirement. I don’t want the apps hidden, but to not steal focus when they’re launched.

1 Like

The method in the last post in this thread will do that.
https://discussions.apple.com/thread/3882355

i.e. Create a script like this:

do shell script "open -g \"/Applications/Microsoft Excel.app\""

tell me to quit

Export it as an application from the script editor. You can place the script application in your dock if you’d like. See the other message thread for changing the icon, if desired.