views:

37

answers:

1

I want to respond to a certain type of new window being opened by an external application. I have some experience finding applications and windows currently open (system wide) using some of the carbon functionality, so could theoretically just check every few seconds. This would require getting a list of all open windows and checking it against some list I would have to maintain, and feels very clunky.

How can I get a simple, clean notification when a new window is launched? Should I use the accessibility API? If so, what specifically am I looking for?

A: 

First, create an AXObserver. Then, watch for launches of any applications that you think you'd be interested in. When such a launch occurs, create an application AXUIElement for that process, and add your observer to it for the kAXWindowCreatedNotification notification.

I question whether this is the best way to do whatever you're trying to do. You might step back a bit from this solution (that is, watching for new windows) and ask another question about your goal.

Peter Hosey
Thanks - AXObserver is exactly what I needed.I know it sounds like a peculiar way to do things but I seriously doubt there is an alternative for my specific application.
Ben Packard