First create an AXObserver. Then follow the launches of any applications that you think you are interested in. When such a launch occurs, create the AXUIElement application for this process and add an observer to it for notification kAXWindowCreatedNotification.
I doubt this is the best way to do what you are trying to do. You can step back a bit from this decision (that is, watch for new windows) and ask another question about your purpose.
source
share