I'm talking about Mac OS X. Can I count the amount of menu items currently displayed for the active window? Can I get their text? Thanks.
Asked
Active
Viewed 1,253 times
1 Answers
0
Yes, using the accessibility API.

LaC
- 12,624
- 5
- 39
- 38
-
2And [the docs for doing this for any application's menus](http://developer.apple.com/library/mac/documentation/Accessibility/Reference/AccessibilityCarbonRef/). – Peter Hosey Jul 05 '11 at 09:08
-
Thanks! Do I understand it correctly, that I need to invoke [element accessibilityAttributeValue:NSAccessibilityChildrenAttribute] and then go through the elements ask them for their role using [child stringValueForAttribute:NSAccessibilityRoleAttribute]? – Aleks N. Jul 05 '11 at 12:26
-
Here is also some useful piece of technique: http://stackoverflow.com/questions/6178860/getting-window-number-through-osx-accessibility-api Thank to all of you guys! – Aleks N. Jul 05 '11 at 12:32
-
Updated [link to the docs](https://developer.apple.com/library/content/documentation/Accessibility/Conceptual/AccessibilityMacOSX/) – Rob Keniger Mar 16 '18 at 02:01