Re: Tracking frontmost App
Re: Tracking frontmost App
- Subject: Re: Tracking frontmost App
- From: "Corey O'Connor" <email@hidden>
- Date: Fri, 13 Oct 2006 11:54:32 -0700
On 10/13/06, Tommy Nordgren <email@hidden> wrote:
Are there any (Preferably Cocoa) api that allows an application to be
notified whenever
the frontmost App changes (for example from XCode to Interface Builder).
I want this in order to implement a time tracking application.
I've accomplished this with a combination of the Accessibility APIs
and NSWorkspace notifications. The process was much like this:
1. On application start find all running applications and register for
their "application activated" events using the accessibility API.
2. Register a class to respond to the NSWorkspace "application
launched" and "application terminated" notifications. On launch add
the application to the list of applications my application is
monitoring using the Accessibility APIs. On terminate, remove the
application.
This worked OK. While I ended up using a different solution for my
purposes I managed to track application activations OK. There was some
confusion on whether a launched application should be treated as also
an application activated event; The app wouldn't necessarily receive
and activation event for the application that notified my app of it's
launch.
I just found this tech note: http://developer.apple.com/technotes/tn/tn2050.html
Which describes a method of monitoring application lifetimes in better
detail than I just did.
--
-Corey O'Connor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden