Re: How to tell if app launched via login item (versus manual launch)
Re: How to tell if app launched via login item (versus manual launch)
- Subject: Re: How to tell if app launched via login item (versus manual launch)
- From: Ken Thomases <email@hidden>
- Date: Wed, 26 Nov 2008 01:33:55 -0600
On Nov 26, 2008, at 12:38 AM, Mark Aufflick wrote:
I'm wondering if it's possible to tell if my application was launched
normally by the user, or if it was launched by virtue of being in the
login items.
You need to look up the Apple Event that is current at the time of
your application's launch. Use [[NSAppleEventManager
sharedAppleEventManager] currentAppleEvent].
If you're in applicationWill/DidFinishLaunching:, then it should be an
"open application" (kAEOpenApplication, a.k.a. 'oapp') event. Then,
check the keyAEPropData parameter to see if it matches
keyAELaunchedAsLogInItem:
if ([[event paramDescriptorForKeyword:keyAEPropData] int32Value] ==
keyAELaunchedAsLogInItem)
// ...
(Note that the parameter may not be present, in which case messaging
to nil will cause the above 'if' condition to evaluate to false.
That's probably what you'd want, but just wanted to be clear.)
See here:
http://developer.apple.com/documentation/Carbon/Reference/Apple_Event_Manager/Reference/reference.html#/
/apple_ref/doc/uid/TP30000134-CH4g-SW1
Cheers,
Ken
_______________________________________________
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