Using the accessibility API, I am drilling down through a series of elements and finding a specific AXUIElementRef I am interested in (all in an external application). How do I check if this element currently has keyboard focus? And if not, how do I set it?
Something similar to using AXUIElementSetAttributeValue to set the kAXMainAttribute to开发者_开发技巧 true (this works for a window - thanks Peter!).
PS - I have tried kAXFocusedAttribute, doesn't seem to do the job. Maybe it's read only?
PS - I have tried kAXFocusedAttribute, doesn't seem to do the job. Maybe it's read only?
Quite the opposite. Read the header:
Writable? Yes, for any focusable element. No in all other cases.
Make sure you've activated the application (by setting its kAXFrontmostAttribute
to true) and made the window key (by setting its kAXFocusedAttribute
to true) before you give a control in the window focus (by setting its kAXFocusedAttribute
to true).
精彩评论