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 13:46:22 -0400
- Thread-topic: Receive notifications about frontmost application change
on 2008-07-09 11:44 AM, Jens Alfke at email@hidden wrote:
> On 9 Jul '08, at 3:22 AM, Александр Даровских wrote:
>
>> Hi,
>> Is there any way to subscribe to frontmost application change
>> notification? For example, via NSDistributedNotificationCenter or
>> some other facility? I have managed to get process startup and
>> shutdown notifications, but I cannot get active application change
>> notification. Maybe it is done in somehow another way?
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.
--
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