I'm trying to open the app Spotify, and move it to the background. I can easily open Spotify with
SpotifyApplication *Spotify = [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
[Spotify activate];
But Spotify goes to the foreground, covering my windows. With iTunes, I can use
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
[iTunes run];
However it's an iTunes specific method. Is this possible?
Would you be willing to use NSAppleScript
to do it?
NSAppleScript *script = [[NSAppleScript alloc]
initWithSource:@"tell app \"Spotify\" to launch"];
NSDictionary *errorInfo;
[script executeAndReturnError:&errorInfo];
if (errorInfo) {
NSLog(@"error: %@", errorInfo);
}
You have to use the application name, not its bundle ID.