[jawsscripts] New way to trace events and callbacks starting in JAWS 14

  • From: Doug Lee <doug.lee@xxxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 1 Nov 2013 10:08:09 -0400

Sort of a public service post here... findings I made in the last two
days in JAWS 14, also applying to JAWS 15.

There is a new way to trace events, or more generally, functions
called directly from JAWS. This includes events, Braille callbacks
like BrailleAddObject*, and functions called by JAWS because of a
scheduleFunction call. Only functions with actual code to run show
up here; e.g., if a WindowActivatedEvent fires or you say
scheduleFunction("xyz", 5) but no windowActivatedEvent or xyz()
function exists, the below trick will not see that call attempt.
(There's a WindowActivatedEvent in default.jss though, so that one
at least will appear.)

How to do this:

addHook(HK_Event_Trace, "myTracer")
; myTracer() will get called just before each function JAWS itself calls that 
exists...
removeHook(HK_Event_Trace, "myTracer")
; But not anymore.
; HK_Event_Trace is defined in HJConst.jsh.

void function myTracer(string jsbPath, string funcName, ...)
; "..." above can be whatever you like; see below.
endFunction

What is passed to the trace function: First the full path to the jsb
file that contains the function that is about to execute. Second, the
name of the function about to be called. Then all the parameters that
are going to be passed to that function. Sadly, we have no way in JAWS
scripting to detect with absolute certainty the count or types of
these parameters, but we can still do stuff like this:

void function myTracer(string jsbPath, string funcName, handle hwnd)
if stringStartsWith(funcName, "window") && stringRight(funcName, 5) == "event"
        ; Announce what's being done to the window by its name.
        ; All window*event functions take an hwnd as first parameter.
        ; Example output: "JAWS Script Manager - [default.jss] resized"
        ; Don't try this at home unless you want a lot of speech!
        var string verb = stringChopLeft(stringChopRight(funcName, 5), 6)
        sayString(formatString("%1 %2",
                getWindowName(hwnd), verb
        ))
endIf
endFunction



-- 
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: