Re: Finding Source of Apple Event
Re: Finding Source of Apple Event
- Subject: Re: Finding Source of Apple Event
- From: email@hidden
- Date: Mon, 5 Feb 2007 16:42:18 +0100
Hello Tommy,
This is not entirely trivial, but here is a method that I use. It
shows you the most important steps:
- (void)handleOpenDocumentsEvent:(NSAppleEventDescriptor *)event
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
OSErr err;
ProcessSerialNumber appPSN;
DescType returnedType;
Size actualSize;
NSDictionary *appInfo;
appPSN.highLongOfPSN = 0;
appPSN.lowLongOfPSN = kNoProcess;
appInfo = nil;
// Whodunnit?
err = AEGetAttributePtr([event aeDesc], keyAddressAttr,
typeProcessSerialNumber,
&returnedType, &appPSN, sizeof(appPSN),
&actualSize);
if (noErr == err && kNoProcess != appPSN.lowLongOfPSN)
{
appInfo = (NSDictionary *)ProcessInformationCopyDictionary
((const ProcessSerialNumberPtr)(&appPSN),
kProcessDictionaryIncludeAllInformationMask);
[appInfo autorelease];
}
// The appInfo will contain all the information from the source
...snip...
}
Cheers!
Annard
On 5 Feb 2007, at 02:16, Tommy Nordgren wrote:
How can I find the App originating an Apple Event in Cocoa?
I need to do special processing when receiving Apple Events from a
particular App.
----
Kine dies, Kinfolk dies, and thus at last yourself
This I know that never dies, how a dead mans deeds are deemed. --
Elder edda
Tommy Nordgren
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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