Re: Who's launching me?
Re: Who's launching me?
- Subject: Re: Who's launching me?
- From: Greg Robbins <email@hidden>
- Date: Wed, 15 Feb 2006 09:20:31 -0800
>In thinking about this more, that's insufficient. I really want
>to know which process called me telling me to open a document.
Handle the OpenDocuments event manually:
NSAppleEventManager *aeMgr = [NSAppleEventManager sharedAppleEventManager];
[aeMgr setEventHandler:myOpenDocumentsHandlerObject
andSelector:@selector(myHandleOpenDocuments:withReplyEvent:)
forEventClass:kCoreEventClass
andEventID:kAEOpenDocuments]; // AppleEvents.h
then in the handler get the sender from the keyAddressAttr attribute of the Apple event:
- (void)myHandleOpenDocuments:(NSAppleEventDescriptor*)odocEvent
withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
NSAppleEventDescriptor *theAEAddrDesc
= [odocEvent attributeDescriptorForKeyword:keyAddressAttr];
// the keyAddressAttr may be a ProcessSerialNumber or an OSType;
// look for either
NSData *thePSNData
= [[theAEAddrDesc coerceToDescriptorType:typeProcessSerialNumber] data];
if (thePSNData && ([thePSNData length] == sizeof(ProcessSerialNumber))) {
ProcessSerialNumber thePSN
= *(ProcessSerialNumber*) [thePSNData bytes];
// use thePSN with Processes.h calls to get other info about the
// sending app, including the signature
}
else {
NSData *theOSTypeData
= [[theAEAddrDesc coerceToDescriptorType:typeApplSignature] data];
if (theOSTypeData && ([theOSTypeData length] == sizeof(OSType))) {
OSType theSignature
= *(OSType*) [theOSTypeData bytes];
// this is the signature of the sending app; the PSN is
// unspecified, though most likely Processes.h calls will only show
// one running instance
}
}
... // you should ignore the replyEvent parameter
}
_______________________________________________
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