On 9 Jul 2008, at 18:46, Bill Cheeseman wrote:

on 2008-07-09 11:44 AM, Jens Alfke at [EMAIL PROTECTED] 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.

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).

Jamie._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to