[jawsscripts] Re: Jaws not speaking Alerts automatically in Chrome or Edge

  • From: Udo Egner-Walter <udo.egner-walter@xxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Sat, 2 Apr 2022 17:36:05 +0200

Hi John, 

Based on your HTML-Example I did some scripting to find out why JAWS isn't 
reading the dialog text. 

I found out if I execute the button a normal FocusChangedEventEx occurs. The OK 
button of the dialog gets the focus and JAWS speaks it. So I''ve overwritten 
the FocusChangedEventEx and added some lines to detect if the current focus is 
in a dialog. 

It's a quick code so there are some things to optimize (for example make the 
FSUIA object a global one because it's not necessary to create one each time 
the FocusChangedEvent fires. But I think you will get the idea and change it to 
your needs: 

Attention: Some mail clients treat line breaks in different way so maybe you 
have to join some lines by yourself. If you can't determine the lines let me 
know snd I can sent you the code off list. 

<Code start>

void function FocusChangedEventEx (handle hwndFocus, int nObject, int nChild,  
handle hwndPrevFocus, int nPrevObject, int nPrevChild, int nChangeDepth)
var
; create FSUIA object
object oUIA = CreateObjectEx ("FreedomSci.UIA", 0, "UIAScriptAPI.x.manifest"),
; get the FSUIAElement with focus(= OK button in your example)
object oFocusElement = oUIA.GetFocusedElement(),
object oFound,
; get the FSUIAElement of the main app window (from which we will search later) 
object oAppElement = oUIA.GetElementFromHandle (GetAppMainWindow (GetFocus())),
; make a search condition, search by ClassName which is "RootView" in our 
example
object oCondition = oUIA.CreateStringPropertyCondition(UIA_ClassNamePropertyId, 
"RootView"),
; we need a TreeWalker to get the first FSUIAElement of a tree branch
object oTree = oUIA.CreateTreeWalker(oUIA.CreateRawViewCondition())
; allocate the FSUIAElement with focus to the TreeWalker
oTree.CurrentElement = oFocusElement
; go to the first FSUIAElement of the same branch
While oTree.GoToPriorSibling ()
EndWhile
        ; If this class name of this FSUIAElement is 
"JavaScriptTabModalDialogViewViewsä" then
        If oTree.CurrentElement.ClassName == 
"JavaScriptTabModalDialogViewViews" then
        ; Say that this is a dialog (deactivated) 
        ; SayString ("It's a dialog")
        ; Let's search out ClassName beginning from the app FSUIAElement down 
the tree
        oFound = oAppElement.FindFirst (TreeScope_Descendants, oCondition)
        ; The text we want is in the property FullDescription 
        ; here you can optimize the code, make error handling and so on
        SayString (oFound.FullDescription)
        ; after speaking the text the standard FocusChangedEventEx should be 
called 
        ; to speak the button  as well (or you can comment it out if you don't 
need it spoken) 
        FocusChangedEventEx (hwndFocus, nObject, nChild, hwndPrevFocus, 
nPrevObject, nPrevChild, nChangeDepth)
        else
        ; dialog was not detected so call the standard event
        FocusChangedEventEx (hwndFocus, nObject, nChild, hwndPrevFocus, 
nPrevObject, nPrevChild, nChangeDepth)
        EndIf ;  If oTree.CurrentElement.ClassName == 
"JavaScriptTabModalDialogViewViews" then
EndFunction

<Code end>

Hope it helps, 
happy scripting 
Udo 



Am 01.04.2022 um 21:59 schrieb John Robichaud <John_Robichaud@xxxxxxxxxxx>:

We're using Jaws 2021 with the Chrome browser to access a custom database
app at a large corporation.
When this app uses the Windows Alert method to display a dialog box, Jaws
does not speak the content of the dialog box automatically.  It does
automatically speak the heading of the Alert box but not the actual message.
In the Edge browser we get the same behavior except, in Edge, Jaws does
automatically speak the button along with the headings but still not the
actual message.



The developer sent me the sample html code below that is the way he is using
Alerts.  He insists that the automatic speaking issue is a Jaws problem.
Does anyone have any idea why Jaws doesn't automatically speak such alerts?

<html>

<body>

<h1> The Window Object</h1>

<h2> The alert Method </h2>



<p>Click the button to display an alert box.</p>



<button onclick= "myFunction()">Try it</button>



<script>

function myFunction() {alert("Hello! I am an alert box!")}

</script>



</body>

</html>



John Robichaud





__________�

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: