Re: App Listener?
Re: App Listener?
- Subject: Re: App Listener?
- From: Rainer Brockerhoff <email@hidden>
- Date: Thu, 8 Jan 2009 15:06:11 -0200
At 15:09 +0000 08/01/09, James Montgomerie wrote:
>On 8 Jan 2009, at 14:14, Rainer Brockerhoff wrote:
>>Today, the only solution seems to be to install a Carbon Event handler for the {kEventClassApplication, kEventAppFrontSwitched} event.
>
>If you don't mind asking your users to switch on accessibility access ("enable access for assistive devices" in the Universal Access preferences), you can use the Accessibility APIs to monitor app switching (this is what's used in the iChatStatusFromApplication sample code, for example - http://developer.apple.com/samplecode/iChatStatusFromApplication/).
I'm using accessibility for other purposes too, so that's the first thing I tried.
The restriction on that is that you have to register for each application you need to watch, it's not a general notification. It also means you have to use other notifications to watch for applications to start up and quit, keep a list of running applications, etc. Lots of overhead and opportunities to go wrong.
For completeness, I'd like to mention that you don't need to ask the user to switch on accessibility if you use the APIs from a background process that's been authorized via AXMakeProcessTrusted().
>I say this informationally - I don't think it's a great solution either.
Exactly.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
_______________________________________________
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