[jawsscripts] Re: An interesting scripting problem

  • From: Steve Matzura <number6@xxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Sun, 06 May 2012 17:30:25 -0400

An interesting take. Problem is, if the window isn't there, what kind
of error will I get back from the calling line?

Anyway, I did solve the problem, and here's the script for it. Sorry
about the bad line-wrapping.

include "hjconst.jsh"

Script FocusSearchList ()

; This script, attached to CTRL+Shift+L, ensures
; PC cursor is on a particular control before doing anything else.

var handle hWin1, handle hWin2,
    int x

let hWin1 = GetCurrentWindow ()
if GetControlID (hWin1) != 1001
        then
                SayMessage (ot_jaws_message, "Place the PC Cursor on
the search edit field before executing this script.", "PC Cursor to
search field first.")
                return
endif

let hWin1 = GetParent(hWin1) ; Go up one level.
let x = TRUE

while x

        let hWin2 = GetNextWindow (hWin1) ; Go right one window.
if GetControlID (hWin2) == 1019 ; Window not accessible via normal tab
; controls
        then
                SetFocus (hWin2) ; Force the PC Cursor to that window.
                let x = FALSE ; Terminate the while condition.
        else
                let hWin1 = hWin2 
; Save the current window handle for the next go-round.

Endif

EndWhile

; Script should always find the window with control ID 1019 this way.
; Question: What value would hWin2 have if it got to the 
;rightmost window and couldn't find the one with control ID 1019?

EndScript


On Sun, 6 May 2012 08:05:10 -0700, you wrote:

>You can use the function IsWindowVisible()
>That will tell you if it is present or visible rather.
>John
>-----Original Message-----
>From: jawsscripts-bounce@xxxxxxxxxxxxx
>[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Steve Matzura
>Sent: Sunday, May 06, 2012 7:34 AM
>To: jawsscripts
>Subject: [jawsscripts] An interesting scripting problem
>
>I'm scripting an application that has a window that's sometimes there,
>sometimes not. The first order of business is to check if the window is
>there, and if it is, set focus to it. I know the control ID of the window,
>1019. I'm trying to use FindDescendantWindow with a start handle of 0 to
>verify its existence. My script so far looks like this:
>
>Script ReadSearchStatus ()
>
>var handle hwin
>
>let hwin = FindDescendantWindow (0, 1019)
>
>if hwin > 0
>then
>Say ("search window present.", ot_jaws_message, false)
>
>; Insert code to set focus to the window. Should I even bother ; with this?
>; Should I just try setting focus and if it fails, assume the window's ; not
>present?
>
>else
>Say ("search window is not present.", ot_jaws_message, false)
>
>endif
>
>EndScript
>
>The problem is, it always comes up saying the window is present, even when
>it's not.
>__________o?=
>
>View the list's information and change your settings at
>//www.freelists.org/list/jawsscripts
>
>__________�
>
>View the list's information and change your settings at 
>//www.freelists.org/list/jawsscripts
>
__________�

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

Other related posts: