Re: Is it possible to get the ElementRef executed by the keyboard?
Re: Is it possible to get the ElementRef executed by the keyboard?
- Subject: Re: Is it possible to get the ElementRef executed by the keyboard?
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 07 May 2008 05:19:34 -0400
- Thread-topic: Is it possible to get the ElementRef executed by the keyboard?
on 2008-05-06 10:29 PM, Brian Krisler at email@hidden wrote:
> Is there a method for accessing the AXUIElementRef for the element
> that was just executed via a keyboard shortcut?
>
> For example, if I select "Select All" from the menu, I can use
> AXUIElementCopyElementAtPosition,
> to get the element accessed via the mouse, but I would like the
> opposite,
> Command-A, was the Select all element.
The answer depends critically on why you want to do this. The Accessibility
API is pretty much about reading and controlling the Graphical User
Interface, not the keyboard interface. If you want to know something more
general than simply finding which menu item is associated with a particular
key combination, you'll have to look beyond the Accessibility API.
This is because a keyboard shortcut can be associated with more than one UI
element, or none at all. For example, two menu items and a button might
perform the same action that a particular keyboard shortcut performs. So if
it is useful in your application to know what UI elements perform the same
action as a particular keyboard shortcut, you would have to find some API
for searching all the UI elements to find those that perform the keyboard
shortcut's action. Since there are many ways that a UI element can be
associated with an action, this may be an insurmountable task.
If you're satisfied to narrow your search to menu items, and if you care
only about the actual key combination rather than the action that it
performs, you could use the Accessibility API to navigate through all the
menu items in the target application's menu bar, and perhaps in all of its
contextual menus and popup menu buttons, as well. Then, for each menu item,
examine whichever of the following Accessibility attributes are of interest:
AXMenuItemCmdChar, AXMenuItemCmdGlyph, AXMenuItemCmdModifiers,
AXMenuItemCmdVirtualKey, AXMenuItemMarkChar and AXMenuItemPrimaryUIElement.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden