Re: Can I Send Apple Events in Cocoa?
Re: Can I Send Apple Events in Cocoa?
- Subject: Re: Can I Send Apple Events in Cocoa?
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 10 Dec 2005 06:49:03 -0500
- Thread-topic: Can I Send Apple Events in Cocoa?
on 2005-12-10 12:07 AM, Kaydell Leavitt at email@hidden wrote:
>
I need to send an Apple Event to a program to automate
>
exporting of data from it to a web-site.
>
>
As far as I can tell, I can receive Apple Events in
>
Cocoa, but I can't send them directly.
Cocoa doesn't have its own facility to send Apple events, but it's easy
enough to use AESendMessage once you've built up the Apple event. You can
built up the Apple event using the appropriate Cocoa classes.
There are many ways to do messaging in Mac OS X, and Apple events certainly
have their place. This is especially true when you want to control or read
another application that is AppleScriptable, and when you want to send one
of the core Apple events to which all applications respond, such as 'quit'.
Here's how I send a 'quit' Apple event to my helper application, using Cocoa
as much as I can:
- (void)stopUIActions {
if ([self isUIActionsRunning]) {
OSType signature = 'UIAc';
NSAppleEventDescriptor *applicationDesc = [NSAppleEventDescriptor
descriptorWithDescriptorType:typeApplSignature bytes:&signature
length:sizeof(OSType)];
NSAppleEventDescriptor *quitApplicationAppleEvent =
[NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
eventID:kAEQuitApplication targetDescriptor:applicationDesc
returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID];
AppleEvent *quitApplicationAppleEventPtr = (AEDesc
*)[quitApplicationAppleEvent aeDesc];
if (quitApplicationAppleEventPtr) {
AESendMessage(quitApplicationAppleEventPtr, NULL, kAENoReply,
kAEDefaultTimeout);
}
}
}
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software -
http://www.prefab.com/scripting.html
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden