osx - How do you get current keyboard focus coordinates in Mac OS X's Accessibility API? -
i'm looking mac os x accessibility api coordinates of location of current keyboard (not mouse) focus. according page 2 of document found @ http://www.apple.com/accessibility/pdf/mac_os_x_tiger_vpat.pdf, it's doable:
supported: mac os x exposes location of current keyboard , mouse focus assistive technologies via accessibility api , provides visual indication of focus on-screen.
despite statement above, can't seem find api itself. i'm seasoned dev (coding since 1982), have never developed on mac os x; please gentle.
osx appears have asymmetric accessibility api; can use nsaccessibilityprotocol make own app accessible, access accessibility of app, have use separate set of interfaces/objects, axuielement , friends.
i found article on retreiving window has focus may of use here: seems key steps are:
- use axuielementcreatesystemwide create 'system wide' accessibility object
- ask object focused application calling
axuielementcopyattributevalue
askingkaxfocusedapplicationattribute
ask returned object focused window again using- looks can skip step below, , go straight focused application focused ui element...axuielementcopyattributevalue
, timensaccessibilityfocusedwindowattribute
- ask returned object focused element using same api again, time
nsaccessibilityfocuseduielementattribute
- ask element kaxsizeattribute / kaxpositionattribute
you might want check out source code uielementinspector displays information element under mouse pointer (though doesn't appear focus).
also looks you'll need enable accessibility api either via gui (see article above) or via terminal of above work - presumably give users defense against rogue apps taking control of desktop.
i haven't used of these (yet); i'm familiar enough accessibility apis know - hope helps.
Comments
Post a Comment