开发者

Objective-C launch iTunes in background

开发者 https://www.devze.com 2023-02-19 23:11 出处:网络
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 w

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

0

精彩评论

暂无评论...
验证码 换一张
取 消