Re: Receive notifications about frontmost application change
Re: Receive notifications about frontmost application change
- Subject: Re: Receive notifications about frontmost application change
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 09 Jul 2008 17:47:23 -0400
- Thread-topic: Receive notifications about frontmost application change
on 2008-07-09 1:58 PM, James Montgomerie at email@hidden wrote:
>> You can register to observe the accessibility notifications
>> AXApplicationActivated and AXApplicationDeactivated. These require
>> you to
>> register to observe a specific target application. Therefore, in
>> order to
>> catch every application switch, use the NSWorkspace -activeApplication
>> method to get the name of the current active application, register to
>> observe when it deactivates, then when it does deactivate get the new
>> -activeApplication and register to observe when it deactivates, and
>> so on.
>>
>> See Apple's iChatStatusFromApplication sample code for Leopard to see
>> exactly how to implement this.
>
> This does require, though, that the user has "Enable access for
> assistive devices" enabled in the Universal Access preferences pane
> (the Carbon method does not).
In Leopard, you can make your application process trusted by the
accessibility API (requires user authentication), using the
AXMakeProcessTrusted function. Then you don't need to ask your users to
enable global access for assistive devices. However, making your process
trusted is not easy -- you have to embed a couple of helper applications in
your application package, one of them to run as root and make your process
trusted, and the other to relaunch your application so the newly-trusted
process is running. If you have an easier way to accomplish your goal, go
for it.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
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