[jawsscripts] Re: find descendent window

  • From: Doug Lee <doug.lee@xxxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Thu, 28 Nov 2013 17:45:41 -0500

Window hierarchy position is not guaranteed to stay constant any more
than the positions of cars in a McDonald's drive-through line are sure
to be the same every morning. Some do stay constant, but there are
things that commonly change this. For example, when you switch tabs in
a tab control, the newly selected tab's container window will often
move to a getHierarchyX position of 1 at its level. This is because it
is advancing to the top of what is called Z order. Z order and
WindowHierarchyX are basically the same thing, a fact that escaped my
attention for many scripting years. A similar thing can happen when
you use Ctrl+Tab to move among subparts of a multi-window app that
uses MDI windows. Windows can also get created and destroyed as you
enable or disable parts of dialogs in some applications.

I'd say identifying the window you want reliably is a similar problem
to identifying a friend reliably: What characteristics make the window
or friend unique depends on who or what else is around. "The girl on
stage" doesn't work when it's a women's choir up there, but "the tall
one with the bright shirt" just might. Part of window identification,
then, is about figuring out what stays unique for your window in the
situations when you need it. Its window class won't change in most
cases, but you have to know if others of that class exist. More than
once I've tried findWindow(getTopLevelWindow(getFocus()), "Internet
Explorer_Server", "") only to discover that an invisible Internet
Explorer_Server can exist in a subregion of the app I hadn't been
paying attention to. If you don't mind a bit of drudgery for the sake
of robustness, you can always use EnumerateChildWindows() and write a
callback function for it that sifts among all the matches to your
first test, like window class, to find the one you really want.

On Fri, Nov 29, 2013 at 08:56:26AM +1100, Geoff Chapman wrote:
Doug this is probably a totally stupid newby green question to ask, but, 
why, goodness me why, for such a seemingly so regularly needed and useful 
type of functionality, wouldn't there be a more elegant way in jaws of 
locating a given window?

i guess there *must* be a technical reason other than mere short-sightedness 
on the part of the script language creators, but, is there?
or is it just like the whole Aray thing, which it took till jaws 11/12 to 
even introduce, when I remember people had been ruing the lack of such an 
apparently  normative programming language feature, for years before that.


----- Original Message ----- 
From: "Doug Lee" <doug.lee@xxxxxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, November 29, 2013 5:31 AM
Subject: [jawsscripts] Re: find descendent window


> Using hierarchical position to find a window is a bit time-consuming
> if you're trying to get to it, but a bit less if you're just trying
> to identify a window you already have.
>
> GetWindowHierarchyX(hwnd) and GetWindowHierarchyY(hwnd) will give
> you an idea where a window can be found in the hierarchy, provided
> you already have a window handle. The trick here, though, is that
> you need the GetWindowHierarchyX value for each level from that
> window up to the top, if you want to find the window again later.
>
> I say it's time-consuming to find the window later because there's no
> function in JAWS scripting to go straight to the nth window at a
> level, so you have to loop once for each level until you get to the
> right window for that level.
>
> In physical terms, it's like this: I'm hiding out on a leaf.
> GetWindowHierarchyY tells you I'm four branch splits from the tree
> trunk, and getWindowHierarchyX tells you I'm the third leaf on my
> branch. The problem is, you don't know where my branch is on the
> branch it comes from, or where that one is on the one it comes from,
> etc. You need something like, "Go to the second branch from the trunk,
> then the fifth branch from that one, then the second branch from that,
> and then the third leaf on that one." This takes a bit of doing in
> JAWS.
>
> On Thu, Nov 28, 2013 at 12:41:37PM -0500, Bissett, Tom wrote:
> Thanks Dug for responding.  I do get what you are saying.  I was hoping I 
> could maybe find the descendent window by its position in the hierarchy 
> and then grab its handle from there.  This may not have been clear from my 
> original request.
> Maybe this is more clear.  Its may be just to cumbersome to be practical 
> as well.
> Regards
> Tom Bisset
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx 
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Doug Lee
> Sent: November 28, 2013 12:13 PM
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: find descendent window
>
> What I'm about to say is honestly not meant to sound flippant, but I'm 
> still afraid it might:
>
> Most any search tactic will require that you know what you're looking for, 
> so I'm having trouble identifying specifically what is troubling you. 
> FindDescendantWindow requires a control ID. I find useful and unique 
> control IDs rather scarce these days, so I usually use FindWindow instead, 
> as it can search by window class name, window name, or both at once. If 
> your application sports unique and consistent control Ids, you can use 
> findDescendantWindow to good advantage though.
>
> On Thu, Nov 28, 2013 at 11:49:32AM -0500, Bissett, Tom wrote:
> Hi,  I have been trying to figure out how to find a specific descendent 
> window based on higharchy but haven't clude in yet.  FindDescendentWindow 
> requires that you know what you are looking for so this does not work for 
> me.
> Can any one point me in the right direction?
> Thanks
> Tom Bisset
> __________???
>
> View the list's information and change your settings at 
> http://www.freelists.org/list/jawsscripts
>
> --
> Doug Lee, Senior Accessibility Programmer SSB BART Group - 
> Accessibility-on-Demand mailto:doug.lee@xxxxxxxxxxxxxxxx 
> http://www.ssbbartgroup.com "While they were saying among themselves it 
> cannot be done, it was done." --Helen Keller __________???
>
> 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
>
> -- 
> Doug Lee, Senior Accessibility Programmer
> SSB BART Group - Accessibility-on-Demand
> mailto:doug.lee@xxxxxxxxxxxxxxxx  http://www.ssbbartgroup.com
> "While they were saying among themselves it cannot be done,
> it was done." --Helen Keller
> __________???
>
> 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

-- 
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:doug.lee@xxxxxxxxxxxxxxxx  http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller
__________�

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

Other related posts: