AP.
AP.

Reputation: 5323

macos : list windows and detect new windows

I would like to have a list of windows which is quite simple but I need as well to :

Do you have any ideas for this?

Thanks in advance

Upvotes: 3

Views: 925

Answers (2)

Ryan
Ryan

Reputation: 2460

The answer in this post should be quite helpful: How can my app detect a change to another app's window?

If you want to just get windows for your own application you can use

int pid = [[NSProcessInfo processInfo] processIdentifier]; 

Using this information, you could write a class that monitors this information and posts changes to a NSNotificationCenter or calls methods on its delegate.

Upvotes: 1

Thomas Zoechling
Thomas Zoechling

Reputation: 34253

The Son of Grab sample provides code to list windows.
You could poll CGWindowListCreate() timer based, but I suppose there are more elegant solutions.

Maybe you can use NSDistributedNotificationCenter to get global NSWindow Notifications. (Did not try that myself - just a starting point)

Upvotes: 0

Related Questions