Prevent window autoselect on application launch When I am typing in an application (say Terminal), and I want to google something, I open Safari. While safari opens and loads tabs and whatnot, I want to keep typing in terminal to get work done. However, after about a second the Safari window gets automatically selected, and whatever I am in the middle of typing suddenly gets input into safari instead.

So I deal with it and click back on Terminal to keep typing. After another second, Safari reselects itself, and I have the same problem. I click back to Terminal, and it happens a third time.

It's extremely annoying, and can be hazardous, for instance when an alert pops up in the newly launched application and I just happen to hit Enter on my keyboard (expecting it to be input into Terminal), causing the alert to instantly disappear after it pops up, potentially doing unwanted actions on my computer.

I don't know if it happens three times with Safari (it was just an example), but I know it has happened at least three times before with a single application launch.

Is there any way to turn off this feature?
As far as I'm aware, there is no ideal solution, unless you're willing to disable SIP (maybe).

I think your best bet may be the bash command open:

Bash:

open -ga "Google Chrome"


Applescript: 

do shell script "open -ga 'Google Chrome' "


These will open the specificed appliction without stealing focus


  The application names are case sensitive






If I only needed this while using terminal, I'd perhaps use aText to expand open chrome to the above command and so on... Not that it's much shorter, but I'd prefer that.





You can use third party applications to launch apps and scripts: 

Alfred, Launchbar, FastScripts, Apptivate etc... there are tons of apps that do this.

You could also make an Application using Automator.app, that just runs the terminal command and you can add that app to the dock. This has it's own problems though, because the actual application icon will show up in the Dock as soon as you click your custom Dock icon and now you got two icons for the same app in the dock... oh well.





As a side note, you can also open a specific website:

Bash:

open -ga "Google Chrome" "http://askdifferent.com"


Applescript:

do shell script "open -ga 'Google Chrome' 'http://askdifferent.com' "



  In other applications you can open a file by replacing the url with a path to a file.