RE: UIElementInspector with keyboard
RE: UIElementInspector with keyboard
- Subject: RE: UIElementInspector with keyboard
- From: "Chen Wang" <email@hidden>
- Date: Fri, 27 Mar 2009 11:04:52 -0400
- Thread-topic: UIElementInspector with keyboard
What I can see is more than one way to do this, however, each way is not
perfect.
The first way is that you can find the focused application with
kAXFocusedApplicationAttribute or
AXUIElementCreateApplication(frontMostPID), then recursively ask the
focused AXUIElement for its focused child AXUIElement with
kAXFocusedUIElementAttribute. As current focus changes, you can trace
the change by registering kEventAooFrontSwitched carbon event and
kAXFocusedUIElementChangedNotification, or simply poll the focused
AXUIElement. This way is not perfect because some application may not
give you the deepest element, and you have to do further dig by looking
at the AXSeletedTextRange attribute.
The idea in the second way is to find the caret position first, and then
use the caret position instead of the mouse cursor position. The key
issue is that tracing current caret position is a far more complicated
job than tracing the mouse position. It requires a helper component
working in the front-most application's process space, getting current
caret position by sending kEventTextInputOffsetToPos carbon event, and
passing the retrieved position back to the UIElementInspector process
via IPC. This has definitely no fun.
Any better idea from others?
Chen
> Hi Everybody,
>I'm trying to modify the UIElementInspector app, so it can update the
>information on keyboard focus.
>(And not on the mouse position)
>http://developer.apple.com/samplecode/UIElementInspector/index.html
>
>The source code use 'AXUIElementCopyElementAtPosition' to get the
>UIElement where the mouse is.
>I can't find any equivalent the get theUIElement where the keyboard
>focus is.
>
>Any idea how to achieve that?
Confidentiality Notice:
E-mail may be intercepted between the sender and the receiver and is
therefore neither secure nor confidential. Your continued use of e-mail
communication confirms that you accept this risk. If this is an urgent
matter, please contact me at the phone number provided. This e-mail,
including any attachments, is for the sole use of the intended recipient(s)
and may contain private, confidential, and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited. If you
are not the intended recipient or this information has been
inappropriately forwarded to you, please contact the sender by reply
e-mail and destroy all copies of the original.
_______________________________________________
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