[jawsscripts] Re: an issue with a function to find the tab handle, since the tab is on some weard place or of nonstandard, so help is requested.

  • From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Mon, 19 Oct 2009 00:02:07 +1000

wow Don this code looks amazing!

well, amazing to me at any rate.  Thank you soooo much for sharing this.
I've always wanted to see some examples of how people like tool through an
application looking for windows, if their control ID's changed too
dynamically to enable one to just grab it using those, which seems to me to
be mostly the case these days.  so just wanted to say a huge thanks for
posting this. I haven't tried to study it yet, but, after this week and I
finish documentation for this job I did months ago, I'm going to set myself
a task of trying to spend time every week trying to learn to understand code
examples just like this, that I see up here to solve particular problems
etc. it's the only way I think I'm ever gunna learn how to get better at
handling all this stuff.
thanks for all the help you try and give up here man.  your efforts do not
go unnoticed here in Aus.



Geoff c.


From: "Donald Marang" <donald.marang@xxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Thursday, October 15, 2009 4:29 AM
Subject: [jawsscripts] Re: an issue with a function to find the tab handle,
since the tab is on some weard place or of nonstandard, so help is
requested.


> Hi Jitendra,
>
> I am not sure I quite understand your circumstance, so excuse me if I am
way
> off base.  Perhaps it would be easier to find this Tab Control by
searching
> or the specific class.  You would need to use the Home Row utility or BX
to
> find out the exact Class string assigned to that control.  Let me know if
> you need help with this task.  Once you get the Class string, assign it to
a
> constant and use the FindWindow function, with the name string empty.
This
> might look as follows:
>
> Const
>  TAB_CONTROL_CLASS = "BitmapTabCtrl" ; just my value used in the VMware
> Workstation
>
> Handle Function FindTab ()
> Var
>     Handle hTab
>
> Let hTab = FindWindow (GetAppMainWindow (GetCurrentWindow ()),
> TAB_CONTROL_CLASS , "")
>
> I recently wrote a function for VMware Workstation that loops through the
> entire application searching for the active window with the desired class
> that is visible.  I use it to get the handle for various classes such as a
> Tab Control, Tree view, List view and even standard Edit and Button
classes.
> I attempted to repeditedly call FindWindow, but I think FindWindow
searches
> from the last window backward to the first window.  Since my loop starts
at
> the beginning, I just bypassed the FindWindow function and did the
> comparisons myself.  Note that the function returns False (0), if nothing
> was found.
>
> HANDLE Function MoveToClass (string sClass)
> Var
>  Int iLoop,
>  Int iDone,
>  Handle hStart,
>  Handle hSearch,
>  Handle hWnd
>
> Let hStart = GetAppMainWindow (GetCurrentWindow ())
> ; SayMessage (OT_DEBUG, "hStart = " + IntToString (hStart))
> Let hWnd = GetFirstChild (hStart)
> Let iLoop = 1
> While ! iDone
> && iLoop < 1000
>  ; SayMessage (OT_DEBUG, "loop = " + IntToString (iLoop))
>  ; SayMessage (OT_DEBUG, "level = " + IntToString (GetWindowHierarchyY
> (hWnd)))
>  ; SayMessage (OT_DEBUG, "child " + IntToString (GetWindowHierarchyX
> (hWnd)))
>  If GetWindowClass (hWnd) == sClass Then
>   ; Found desired class
>   SayMessage (OT_DEBUG, sClass + " control found!  iLoop = " + IntToString
> (iLoop))
>   ; SayMessage (OT_DEBUG, "level = " + IntToString (GetWindowHierarchyY
> (hWnd)))
>   ; SayMessage (OT_DEBUG, "child " + IntToString (GetWindowHierarchyX
> (hWnd)))
>   If IsWindowVisible (hWnd) Then
>    SayMessage (OT_DEBUG, "control is visible, handle = " + IntToString
> (hWnd))
>    SetFocus (hWnd)
>    Return hWnd
>   Else
>    SayMessage (OT_DEBUG, "control is NOT visible!")
>   EndIf ; visibility check
>  EndIf ; class found!
>  ; traverse to next available window
>  Let hSearch = GetFirstChild (hWnd)
>  If hSearch Then
>   ; move to child
>   Let hWnd = hSearch
>  Else
>   Let hSearch = GetNextWindow (hWnd)
>   If hSearch Then
>    ; move to next window
>    Let hWnd =hSearch
>   Else
>    ; last window in branch, go up as many  levels as needed then to next
> window
>    Let hSearch = StringToHandle ("0") ; cause While loop to execute at
least
> once
>    While ! hSearch
>    && ! iDone
>     Let hWnd = GetParent (hWnd)
>     If hWnd == hStart Then
>      ; Finished searching, nothing found!
>      ; SayMessage (OT_DEBUG, "hWnd =  hStart = " + IntToString (hWnd))
>      Let iDone = True
>     Else
>      Let hSearch = GetNextWindow (hWnd)
>     EndIf ; back to top level
>    EndWhile
>    Let hWnd = hSearch
>   EndIf ; next window available
>  EndIf ; child available
>  Let iLoop = iLoop + 1
> EndWhile
> SayMessage (OT_DEBUG, "searched all " + IntToString (iLoop) + " windows;
> Could not find any more " + sClass + " Controls!")
> Return False
> EndFunction
>
> Don Marang
>
>
> ----- Original Message ----- 
> From: "Jitendra" <jeet.invincible@xxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Wednesday, October 14, 2009 10:00 AM
> Subject: [jawsscripts] an issue with a function to find the tab handle,
> since the tab is on some weard place or of nonstandard, so help is
> requested.
>
>
> > Hello friends, as subject says half of it, I have created a function to
> > provide the handle for the tabstrip or the tab control class, since I am
> > not much friendly with such things, your help is appriciated and
required.
> > the problem is that this function does not give the handle, so the code
> > is below and help me out on it.
> > handle Function FindTab ()
> > Var
> > Int Icount,
> > Handle hwnd,
> > String SRealName
> > Let ICount=0
> > Let SRealName=GetWindowName (GetRealWindow (GetFocus ()))
> > ;Let SRealName=StringLower (SRealName)
> > If StringContains (SRealName, "Ctrl") ||
> > StringContains (SRealName, "Format") ||
> > StringContains (SRealName, "ToolBar") then
> > Let Hwnd=GetRealWindow (GetFocus ())
> > Let Hwnd=GetFirstChild (Hwnd)
> > ;since the GetWindowHierarchyX function returned 1 here, when the focus
> > was on the tab strip, and in the homerow, this was the first window, I
> > thaught it should work this way.
> > Return Hwnd
> > Elif StringContains (SRealName, "Disk") then
> > Let Hwnd=GetRealWindow (GetFocus ())
> > Let Hwnd=GetFirstChild (Hwnd)
> > While ICount < 3
> > Let Hwnd=GetNextWindow (Hwnd)
> > Let ICount=ICount+1
> > EndWhile
> > ;since the GetWindowHierarchyX function returned 1 here, when the focus
> > was on the tab strip, and in the homerow, this was the fourth window, I
> > thaught it should work this way.
> > Return Hwnd
> > Elif StringContains (SRealName, "BatchMode") then
> > Let Hwnd=GetRealWindow (GetFocus ())
> > Let Hwnd=GetFirstChild (Hwnd)
> > While ICount < 9
> > Let Hwnd=GetNextWindow (Hwnd)
> > Let ICount=ICount+1
> > EndWhile
> > ;since the GetWindowHierarchyX function returned 1 here, when the focus
> > was on the tab strip, and in the homerow, this was the 10th window, I
> > thaught it should work this way.
> > Return Hwnd
> > EndIf
> > EndFunction
> > any light?
> > Thank you, Jitendra.
> > __________
> > Visit and contribute to The JAWS Script Repository
http://jawsscripts.com
> >
> > View the list's information and change your settings at
> > //www.freelists.org/list/jawsscripts
> >
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> //www.freelists.org/list/jawsscripts
>

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

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

Other related posts: