I try to launch an app in the bac开发者_运维百科kground, without activating it. I just this method on NSWorkspace
to launch it in the background :
[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:bundleID
options:(NSWorkspaceLaunchWithoutActivation |
NSWorkspaceLaunchAllowingClassicStartup)
additionalEventParamDescriptor:nil launchIdentifier:NULL];
The only problem is that it doesn't activate the app but it does switch space to the assigned space of that application. Any way to avoid this?
Do you have any control over the app that you're launching? If so, override the window collection behavior of its windows. You'll probably want to make this controllable via a command line argument or similar methods, so the Spaces settings are still respected when the app is launched manually by the user.
If the app that you're launching is not under you control, how about using AppleScript to temporarily override its Space assignment, then change the assignment back to the original value?
精彩评论