Launch an application with NSWorkspace without activating or switching it

I am trying to run the application in the background without activating it. I just have this method on NSWorkspace to run it in the background:

 [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:bundleID options:(NSWorkspaceLaunchWithoutActivation | NSWorkspaceLaunchAllowingClassicStartup) additionalEventParamDescriptor:nil launchIdentifier:NULL]; 

The only problem is that it does not activate the application, but it switches the space to the designated space of this application. Any way to avoid this?

+4
source share
1 answer

Do you have control over the application you are launching? If so, redefine the window behavior of the window of its windows. You probably want to make this manageable with a command line argument or similar methods, so the Spaces options are still respected when the application is started manually by the user.

If the application you are running is not under your control, how about using AppleScript to temporarily override its space assignment , then change the assignment to its original value?

+2
source

All Articles