[jawsscripts] Re: dlgList of buttons

  • From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
  • To: "JAWSScripts" <jawsscripts@xxxxxxxxxxxxx>
  • Date: Tue, 28 Sep 2010 12:26:34 +0100

Hi Mario,

  The FindWindow function seems to be a problem.  Once I got the dialog list
working, I found that FindWindow would not reliably take me to the named
button: it stopped at the first button it found which contained the desired
name as a substring.  So I had to complicate matters by saving an additional
list of button handles as I iterated through the collection.  See below.
This code is working on my version of Calc under XP Home:

Const
sep = "\007"

Script testCalc ()
var
    String sButtons,      ;list of button names
    String sHandles,     ;list of button handles
    String sItem,           ;name of chosen button
    int iIndex,                ;index of button in dialog list
    handle hW              ;general window handle

; find the first child button of Application Main Window
let hW = FindWindow (GetAppMainWindow (GetCurrentWindow ()), "Button", "")

; if current window has the class "Button"
; save its handle and name to separate lists
; then step to next window at this level
while (hW)
    if (StringContains (GetWindowClass (hW), "Button")) then
        let sHandles = sHandles + IntToString (hW) + sep
        let sButtons = sButtons + GetWindowText (hW, false) + sep
    endif
    let hW = GetNextWindow (hW)
endwhile

; request index of required button from dialog list
let iIndex= dlgSelectItemInList (sButtons, "Calculator Buttons", false, 1)

; find corresponding handle
let hW = StringToHandle (StringSegment (sHandles, sep, iIndex))

; Move JAWS cursor to button automatically
MoveToWindow (hW)

; give the cursor time to move and do a left click
Pause ()
LeftMouseButton ()

; give calculator time to respond, change back to PC Cursor
; and speak result in calculator display
Pause ()
PCCursor ()
SayChunk ()
EndScript

  hth

Martin



----- Original Message ----- 
From: "Mario Brusco" <mrb620@xxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Tuesday, September 28, 2010 3:04 AM
Subject: [jawsscripts] Re: dlgList of buttons


> Hi Martin, inserting your while code brings up a empty list, no items
> (buttons). Now to get the button names in there. have any suggestions?
>
> ----- Original Message ----- 
> From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
> To: "JAWSScripts" <jawsscripts@xxxxxxxxxxxxx>
> Sent: Monday, September 27, 2010 6:01 PM
> Subject: [jawsscripts] Re: dlgList of buttons
>
>
> Hi Mario,
>
>  The line in your original code which I mentioned before as being
> commented
> out is actually in the wrong place.  As it stands, you will only look at
> the
> next window
> if the first window you find is a button.  Try this:
>
> while ((hW) && not IsKeyWaiting ())
>  if (GetWindowSubTypeCode (hW) == 1) then
>    let sList = sList + GetWindowName (hW) + sep
>  endIf
>  let hW = GetNextWindow (hW) ;this now happens whether you find a button
> or
> not
> endWhile ;
>
>  hth
>
> Martin
>
> ----- Original Message ----- 
> From: "Mario Brusco" <mrb620@xxxxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Monday, September 27, 2010 10:06 PM
> Subject: [jawsscripts] Re: dlgList of buttons
>
>
>> hi David, which code are your comments referring to, the first or
>> Jackie's?
>>
>> I've added an iCount variable into the while loop as follows:
>>
>> var int iCount,
>> bla bla bla
>> while ... && iCount<100
>> bla bla bla
>> let iCount= iCount+1
>> EndWhile
>>
>> now a jawskey+control+b results as the script not being recognized
>> (shouldn't it be a >100?). but I like your idea too. Exactly where and
>> how
>> would it be implemented without the iCount stuff?(exact code please as I
>> am
>> not a true scripter).
>>
>> I cringe when I need to force boot to get jaws back, and I'd like a sure
>> fire way to prevent jaws from hanging.
>> ----- Original Message ----- 
>> From: "David Farough" <David.Farough@xxxxxxxxxxxxx>
>> To: <jawsscripts@xxxxxxxxxxxxx>
>> Sent: Monday, September 27, 2010 2:02 PM
>> Subject: [jawsscripts] Re: dlgList of buttons
>>
>>
>> hi Mario;
>> You could always add the Not IsKeyWaiting () condition to your while
>> loop.  This will terminate the loop as soon as you hit a key.
>>
>> In the final FindWindow, you should only specify one value in the
>> arguments,  You can specify "" (null string )   . for the class and the
>> name for the window you are looking for.
>>
>>
>> David Farough
>> Application Accessibility Coordinator/coordonateur de l'accessibilité
>> Information Technology Services Directorate /
>> Direction des services d'information technologiques
>> Public Service Commission / Commission de la fonction publique
>> Email / Courriel:  David.Farough@xxxxxxxxxxxxx
>> Tel. / Tél:    (613) 992-2779 >>> Mario Brusco <mrb620@xxxxxxxxxxx>
>> 01:00 PM Monday, September 27, 2010 >>>
>> Nope, still hangs. hmm, I'm wondering if there's a way to avoid the
>> hanging
>> without interfering the intended function of the script, sort of a
>> safety
>> out? I'm wary of forcing to turn off the PC (by holding the power
>> button
>> down until the PC shuts down (cold boot)) in order to get speech back;
>> I've
>> had to do this too many times.
>>
>> ----- Original Message ----- 
>> From: "Jackie McBride" <abletec@xxxxxxxxx>
>> To: <jawsscripts@xxxxxxxxxxxxx>
>> Sent: Monday, September 27, 2010 12:11 PM
>> Subject: [jawsscripts] Re: dlgList of buttons
>>
>>
>> Mario, let's revise the while loop, as follows:
>>
>> var
>> String sList, ;will contain list of buttons
>> String sItem, ;will contain the desired button name
>> int iIndex, ;contains number of button selected
>> handle hW ;contains window handles
>> let hW= FindWindow (GetAppMainWindow (GetCurrentWindow ()), "Button",
>> "")
>> ;looks for a type (Button), starting from main window
>> while (hW) ;while valid window handle found
>> if GetWindowSubTypeCode (hW)== 1 then ;it's a button,gets name of
>> button and
>> adds it to the list, as well as the \007 item separator
>> let sList= sList+GetWindowName (hW)+sep
>>
>> endIf
>> ;let hW= GetNextWindow (hW) ;go to next window
>> endWhile ;displays the list of buttons from which to pick, iIndex
>> returns
>> the button number
>> let iIndex= dlgSelectItemInList (sList, "calculator buttons", 1) ;gets
>> the
>> name of the button selected
>> let sItem= stringSegment (sList, sep, iIndex)
>> let hW= FindWindow (GetAppMainWindow (GetCurrentWindow ()),
>> "Button", sItem)
>> if hW then ;valid window handle
>> SetFocus(hw)
>> TypeKey("space")
>> else
>> SayMessage (OT_MESSAGE, "window not found")
>> endIf
>>
>> EndScript
>>
>>
>> On 9/27/10, Mario Brusco <mrb620@xxxxxxxxxxx> wrote:
>>> hi scripters, I am trying to adapt the following code to retrieve a
>> list
>>> of
>>> the Windows calculator buttons whether it is in standard or
>> scientific
>>> mode,
>>> whether the buttons are disabled or not. It seems to hang at some
>> point.
>>> can
>>> someone please help to get it working for me? Maybe the problem is in
>> the
>>> while loop? I dabble lightly and am not a true scripter yet, so I
>> need
>>> actual code:
>>>
>>> const
>>> sep = "\007"
>>>
>>> Script GetButton ()
>>> ;control+jawskey+b
>>> ; gathers the buttons in a window into a list, user can use arrows to
>> use
>>> the arrow keys and enter key to select a function
>>> ; works in any window/dialog
>>> var
>>> String sList, ;will contain list of buttons
>>> String sItem, ;will contain the desired button name
>>> int iIndex, ;contains number of button selected
>>> handle hW ;contains window handles
>>> let hW= FindWindow (GetAppMainWindow (GetCurrentWindow ()), "Button",
>> "")
>>> ;looks for a type (Button), starting from main window
>>> while (hW) ;while valid window handle found
>>> if GetWindowSubTypeCode (hW)== 1 then ;it's a button,gets name of
>> button
>>> and
>>> adds it to the list, as well as the \007 item separator
>>> let sList= sList+GetWindowName (hW)+sep
>>> ;let hW= GetNextWindow (hW) ;go to next window
>>> endIf
>>> endWhile ;displays the list of buttons from which to pick, iIndex
>> returns
>>> the button number
>>> let iIndex= dlgSelectItemInList (sList, "calculator buttons", 1)
>> ;gets the
>>> name of the button selected
>>> let sItem= stringSegment (sList, sep, iIndex)
>>> SaveCursor ()
>>> JAWSCursor ()
>>> RouteJAWSToPc ();finds the button & gets its handle
>>> let hW= FindWindow  (GetAppMainWindow (GetCurrentWindow ()),
>>> "ThunderRT6CommandButton", sItem)
>>> if hW  then ;valid window handle
>>> if MoveToWindow (hW) then ;move to the window whose handle u just
>> got
>>> LeftMouseButton ()
>>> Else
>>> SayMessage (OT_MESSAGE, "cannot move to button")
>>> endIf
>>> else
>>> SayMessage (OT_MESSAGE, "window not found")
>>> endIf
>>> RestoreCursor ()
>>> EndScript
>>>
>>> __________
>>>
>>> View the list's information and change your settings at
>>> //www.freelists.org/list/jawsscripts
>>>
>>>
>>
>>
>> -- 
>> Change the world--1 deed at a time
>> Jackie McBride
>> Scripting Classes: http://jawsscripting.lonsdalemedia.org
>> homePage: www.abletec.serverheaven.net
>> For technophobes: www.technophoeb.com
>> __________
>>
>> 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
>>
>>
>>>
>> This e-mail message is intended for the named recipient(s) and may
>> contain information that is privileged, confidential and/or exempt from
>> disclosure under applicable law. Unauthorized disclosure, copying or
>> re-transmission is prohibited. If you are not a named recipient or not
>> authorized by the named recipient(s), or if you have received this
>> e-mail in error, then please notify the sender immediately and delete
>> the message and any copies.
>> >
>> Ce courriel est destiné exclusivement au destinataire mentionné en titre
>> et peut contenir de l'information privilégiée, confidentielle ou
>> soustraite à la communication aux termes des lois applicables. Toute
>> divulgation non autorisée, toute reproduction ou réacheminement est
>> interdit. Si vous n'êtes pas le destinataire de ce courriel, ou n'êtes
>> pas autorisé par le destinataire visé, ou encore, si vous l'avez reçu
>> par erreur, veuillez le mentionner immédiatement à l'expéditeur et
>> supprimer le courriel et les copies.
>>
>> __________?
>>
>> 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
>
>
> __________�
>
> 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: