• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Quit iTunes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit iTunes


  • Subject: Re: Quit iTunes
  • From: has <email@hidden>
  • Date: Sat, 24 May 2008 20:38:02 +0100

Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with
NSWorkspace but how about quit?



Send a quit AppleEvent

How would I do that? I have been looking for a while and I found aevtquit but I can't find out how to send.

Example:

#include <Carbon/Carbon.h>

OSStatus QuitApplication(char *bundleID) {
    AppleEvent evt, res;
    OSStatus err;

    err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication,
                            typeApplicationBundleID,
                            bundleID, strlen(bundleID),
                            kAutoGenerateReturnID,
                            kAnyTransactionID,
                            &evt, NULL, "");
    if (err == noErr) {
        err = AESendMessage(&evt, &res, kAENoReply, kAEDefaultTimeout);
        AEDisposeDesc(&evt);
    }
    return err;
}

int main (int argc, const char * argv[]) {
    return QuitApplication("com.apple.itunes");
}


For anything more complex, use a high-level bridge (e.g. see my sig).

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Quit iTunes
      • From: "Mr. Gecko" <email@hidden>
  • Prev by Date: Re: Quit iTunes
  • Next by Date: Re: Quit iTunes
  • Previous by thread: Re: Quit iTunes
  • Next by thread: Re: Quit iTunes
  • Index(es):
    • Date
    • Thread