I want to launch iTunes but i don't want the launch to be visible, at the moment the code i have navigates to the space which iTunes is assigned to and makes iTunes the key window, so effectively i want it to launch in the background.
[[NSWorkspace sharedWorkspace] launchApplication:@开发者_高级运维"iTunes"];
Can anyone help? Thanks.
I think this is what you want:
[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@"com.apple.iTunes" options: NSWorkspaceLaunchDefault | NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor:nil launchIdentifier:nil];
The important bit is NSWorkspaceLaunchWithoutActivation
.
Edit: As also posted, you can use NSWorkspaceLaunchAndHide as well, if you want iTunes to be hidden.
Use -launchApplicationAtURL:options:configuration:error: to launch it, and include NSWorkspaceLaunchAndHide in the options.
Should this work for you?
- (NSRunningApplication *)launchApplicationAtURL:(NSURL *)url options:(NSWorkspaceLaunchOptions)options configuration:(NSDictionary )configuration error:(NSError *)error
精彩评论