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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to