views:

34

answers:

1

Hi guys, I'd like to monitor all windows (include other applications' windows) changes like resizing, hiding, un-hiding etc. I found that if I use

[NotificationCenter defaultCenter]

, I just receive the event from my own application's window. But how about

NSWorkspace's notification center?

+1  A: 

NSWorkspace doesn't have anything to do with windows, so no.

The distributed notification center won't work, either.

Keep in mind that a notification center is not merely a portal by which to observe things; things have to post notifications on it. An NSWindow object does that when the user resizes its window, but it does it only on the default local notification center, not the distributed one nor NSWorkspace's. Therefore, that's the only notification center on which you can observe for window notifications and get anything for it, and you'll only get them about your own windows.

You can use the Accessibility API to observe a property of a window in any process, but notifications won't come in during a drag, only after it, and the user will need to have “Access for assistive devices” turned on.

Peter Hosey
Thank you Peter, it does help. But, any clue of how to monitor these kinds of things, windows resizing, hiding or other things?
icespace
icespace: Accessibility.
Peter Hosey