开发者

Accessibility API - Setting keyboard focus to a specific element

开发者 https://www.devze.com 2022-12-17 14:08 出处:网络
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 cu

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号