[jawsscripts] Re: Some question about UIA

  • From: Udo Egner-Walter <udo.egner-walter@xxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 5 Oct 2018 18:24:24 +0200

Hi,

thank you very much.

Udo



Am 04.10.2018 um 19:53 schrieb Travis Roth:

CreateAndCondition is the same as "and" or "&&" in most languages. It returns 
true when the two conditions it is testing both return true.
CreateAndCondition does this at the UIA level instead of you manually 
checking each condition, which I assume adds an efficiency somewhere.

-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx <jawsscripts-bounce@xxxxxxxxxxxxx> On 
Behalf Of Udo Egner-Walter
Sent: Thursday, October 4, 2018 11:14 AM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Some question about UIA

Hi,

thank you very much for the little code example.

Do you know what "CreateAndCondition" means? Is this a way to merge two 
conditions?

Thanks again and best wishes

Udo



Am 03.10.2018 um 15:56 schrieb Travis Roth:
Hi,
UIA does have GetFocusedElement. However, it is not entirely reliable
and FS made a more robust version.
Touch.jss used to have a definition for
SetCurrentElementToDeepestFocusElement().
I see in JAWS 2018 that they still use it but the code is no longer
listed in touch.jss or at least I am not finding it at the moment, so
not sure how it is being called...

I had copied it out previously and it is:

void function SetCurrentElementToDeepestFocusElement(object oUIA,
object
temptreeWalker)
; from touch.jss circa JAWS 18 version ;More than one element in a
process may show as having the focus, ;this tries to set the current
element to the deepest focus element which is keyboard focusable.
if !oUIA || !temptreeWalker return Null() endIf; var object
focusElement = oUIA.GetFocusedElement().BuildUpdatedCache();
if !focusElement;
     ;Even though there is focus, GetFocusedElement may not retrieve an
element
     temptreeWalker.currentElement =
oUIA.GetElementFromHandle(GetFocus());
     return;
endIf;
var object condition = oUIA.CreateAndCondition(
     oUIA.CreateBoolPropertyCondition(UIA_HasKeyboardFocusPropertyId,
UIATrue),
     oUIA.CreateBoolPropertyCondition(UIA_IsKeyboardFocusablePropertyId,
UIATrue));
if !condition;
     temptreeWalker.currentElement = FocusElement;
     return;
endIf;
;looking for the focus element which is keyboard focusable will cause
a crash if used in the context menu of an item in the system tray:
if focusElement.controltype == UIA_MenuBarControlTypeId &&
focusElement.isOffscreen;
     temptreeWalker.currentElement = oUIA.GetRootElement();
     temptreeWalker.currentElement =
temptreeWalker.currentElement.FindFirst(TreeScope_Subtree,
oUIA.CreateBoolPropertyCondition(UIA_HasKeyboardFocusPropertyId, UIATrue));
     return;
endIf;
temptreeWalker.currentElement = oUIA.GetRootElement(); while
!!FocusElement &&
!oUIA.CompareElements(focusElement,temptreeWalker.currentElement);
     temptreeWalker.currentElement = focusElement;
     focusElement = FocusElement.FindFirst(TreeScope_Subtree, condition
).BuildUpdatedCache(); endWhile; EndFunction


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
<jawsscripts-bounce@xxxxxxxxxxxxx> On Behalf Of Udo Egner-Walter
Sent: Tuesday, October 2, 2018 1:39 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Some question about UIA

Hi UIA experts,
the SetFocus () function can bring the focus to a control if one have
the window handle. I wonder if there is a similar function for UIA or
how to create one.

For example:

var

object oUIA,

string MY_AUTOMATION_ID = "ApplyBtn"

oUIA = GetUIAObjectTree(GetAppMainForm(GetFocus()))

if oUIA then

   Â Â Â Â Â Â Â Â Â Â Â  let oUIA =
oUIA.FindByAutomationId(MY_AUTOMATION_ID)

   Â Â Â Â Â Â Â Â Â Â Â  if oUIA then

   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  ; set the focus ??

   Â Â Â Â Â Â Â Â Â Â Â  EndIf

EndIf

I had a look at JAWS UIA Script API at
https://www.freedomscientific.com/Support/JAWSDocumentation/UIAScriptA
PI
but found it a little confusing.

There are different objects, for example "FSUIA" and "FSUIAElement".
The FSUIAElement has a element "bool SetFocus();".

At the beginning you can read: "The primary object in the JAWS UIA
script API is FSUIA. Using this object, you can get other objects that
represent UIA elements, get tree walkers which will allow you to
traverse the tree of UIA elements, register for UIA events, and more."

But how to get an object UIAElement?

Do someone know: is "oUIA =
GetUIAObjectTree(GetAppMainWindow(GetFocus()))" an object of type
FSUIA and do I need to create an object "FSUIAElement"? How can I do this?

How can I execute a button? Does someone have a code example?

Thank you in advance

Udo




__________�

View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts


__________�

View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts

__________

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts


__________�

View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts


__________�

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: