I need get all elements in the status bar in OSX.
I tried to get the NSStatusBar id of the System: [NSStatusBar systemStatusBar] but I don't know how can I get all NSStatusItems in it. I found a private method named _items in NSStatusBar but I can't call it:
[[NSStatusBar systemStatusBar] _items];
Xcode tould me that that method doesn't exist.
How can I get all NSStatusItem elements in the NSStatusBar?
Thanks
You cannot get all items as
NSStatusItem
objects because they don't all belong to your process.If you're only interested where they are on screen and which apps own them, you can do that with the
CGWindow
APIs, because technically the status items are (borderless) windows. Here's an example that logs information about all status bar items:Note that the system's items are not included; they are all combined in one window that belongs to "SystemUIServer". Also, this method might not be particularly reliable because the window layer for status bar items might change (it's assumed to be 25 here, but this is not documented anywhere).