[jawsscripts] Re: KList.jsl - automatic JAWS keystroke list generation
- From: Jitendra <jeet.invincible@xxxxxxxxx>
- To: jawsscripts@xxxxxxxxxxxxx
- Date: Sat, 27 Sep 2008 10:14:47 -0700
Hello, one question:
as there are countless numbers of viruses and malwares are available, and
many people are using firefox as their default web-browser,
sometimes opening even IE can cause problems, as some codes are planted in
the toolbars of ie,
so is it possible to use KList module to detect and launch the default
browser if set to firefox or any other?
or IE is required,
Thank you.
doug@xxxxxxxxxxxx[1] 09:58 pm Wednesday, February 25, 2004 >>>This is a
firstrelease of a code module that automatically generates and displays a
table of the scripts, keystrokes, and script documentation for the currently
active application or for an application of your choice. This module
requiresJAWS 5.00.621 or later, sadly, because previous JAWS versions
containbugs in the IniReadSectionKeys function that prevent this code from
functioning properly. Around Thanksgiving of last year, when I was supposed
to be taking a long and much-overdue vacation, I somehow managed to write a
fairly major piece of code while my holiday guest Elena, a most dear friend
from Italy, was out shopping and exploring. Whether my coding efforts
reflectmy tendency to like coding or my tendency to hate shopping, who
knows... but in any case, having mentioned this effort and its results a
number of times in the For-The-People scripting forum and in various other
conversations since, I thought I'd post the module here for general
enjoyment. (Actually, I thought I'd already done so, but it seems I never
gotround to it.) What this does: If you call the function
KLShowKeyBindings()with no parameters (or with a null ("") parameter, since
the compiler will probably insist on that), you'll cause a new Internet
Explorer page to open containing a table consisting of a list of all the
scripts with key assignments for the active application. For each entry, the
table will show the script name, the keystroke or keystrokes attached to it,
the synopsis, and the description. (The last two of these come from the .jsd
file for the active application, just as for Keyboard Help mode.) I use this
to get a quick overview of what a script set can do, check for errors in a
jsd file, make sure everything I expect to find keyboard-accessible actually
has a key assignment, etc. I also regard it as an automatic way to get what
insert+h usually gives us but with no extra coding per application script
set. You can also pass a non-null parameter to get the key assignments and
scripts for another application, or even the default assignments. Examples:
KLShowKeyBindings("Internet Explorer 5-6") KLShowKeyBindings("default") As
isindicated in the comments, I am putting this module out for general use
and/or modification, provided that (1) any copy used retains the comments,
including the attributions/authors/versions/etc. at the top, and (2) any
modifications are clearly marked as such, to indicate who made them and how
the modified version differs from this one. I am sending this message to
Freedom Scientific also, as I am curious if this approach, or something like
it, may one day be used to replace or augment the normal insert+h coding now
in common use. This module is 309 lines and 10,574 bytes long. If you use
it,make sure the line count is exact and the byte count is exact or very
close (trailing spaces and such could change that number a bit I suppose).
For a spot-check: The longest line is line 83--a comment beginning with ";
This function references jfw.ini." The very next line begins with "; Return
format." If not, you have a formatting problem... To use this, either copy
itinto a jss file or Include it with an Include line (below the Include line
for hjconst.jsh). Comments welcome. And to Elena, who is also getting this
message, I love you, for who you are and for how well you understand me. I'm
glad you had fun that day too. :-) -------------------- Cut Here
--------------------
;*********************************************************************** ;
@(#) $Id: klist.jsl,v 1.7 2004/02/26 01:45:25 dlee Exp $ ; Module Prefix: kl
; Dependencies: JAWS 5.00.621 or later for bugless IniReadSectionKeys
function. ; Purpose: Provides the KLShowKeyBindings function for displaying
an HTML table of JAWS commands for an application. ; ; Interface:
klShowKeyBindings(appBaseName | "default" | ""). ; ; TODO: ; Braille
keystrokes can appear without the word "Braille" in front of them in this
table. ; Keys for a script can be missed (because getScriptKeyNames misses
them). ; ; Author: Doug Lee of Bartimaeus Group ; Anyone may use this module
as is provided this entire comment block remains. ; Anyone may modify this
module if they also indicate what changes have been made. ; ; Revision
History: ; 07/18/03: Experimental code for making JAWS write and display
HTML(lib/examples/ie.jss). ; 11/18/03: Module started at home (during a long
vacation: Elena went shopping and I wrote over 200 lines of code). ;
12/28/03: First working version (addition of doc object handling mostly,
imported from ie.jss once it was found again). ; 01/19/04: Moved Script
column before Key(s) column. ; 02/25/04: Minor cleanup, removal of external
code dependency, and release to the JAWSScripts list and FS. int function
kl_add(string byRef slist, string s, string delim) ; Adds s to slist unless
it's already there. ; Returns True if slist was changed and False otherwise.
if !stringContains( delim+slist+delim, delim+s+delim) then if slist then let
slist = slist +delim endIf let slist = slist +s return True endIf return
False endFunction string function kl_stringSegmentNext(string byRef s,
stringsep) ; Gets, returns, and removes from s the next string segment and
the trailing separator if any. ; sep may be multi-character and is case
sensitive. ; If sep is null, the entire string is treated as one segment.
varint pos, string s1 let pos = 0 if sep then let pos = stringContains(s,
sep) endIf if !pos || !sep then let s1 = stringChopLeft(" " +s, 1) ; avoids
pointer duplication let s = "" return s1 endIf let s1 = stringLeft(s, pos-1)
let s = stringChopLeft(s, pos +stringLength(sep) -1) return s1 endFunction
int function kl_readKeySection(string fileName, string sectName, string
byRefscriptList) ; Include in scriptList all the scripts referenced by the
indicated .jkm section. ; Returns True if any scripts were added and False
otherwise. var string keyList, string keyName, int changed let keyList =
INIReadSectionKeys(sectName, fileName) let changed = False while True let
keyName = kl_stringSegmentNext(keyList, "|") if !keyName then return changed
endIf if kl_add(scriptList, iniReadString(sectName, keyName, "", fileName),
"|") then let changed = True endIf endWhile ; line not reached. endFunction
string function kl_getSectNames() ; Returns the verticalbar-separated list
of.jkm sections to seek/read. ; Tries to include all sections that apply to
the current keyboard layout and Braille display. ; This function references
jfw.ini and user.ini in the JAWS directory and default.jcf and default.jkm
inthe JAWS settings directory. ; Return format: "<layoutName> Keys|Common
Keys[|<BrailleDisplayName> Keys]." ; Example: "Desktop Keys|Common Keys|PB80
Keys." var string jdir, string jsdir, string temp, string layoutBase, string
layouts let jdir = getJAWSDirectory() +"\\" let jsdir =
getJAWSSettingsDirectory() +"\\" ; Get the base name of the effective
keyboard layout. ; This can be found in [options] of user.ini if
nonstandard.; Example line: KeyboardType=Desktop. ; This code assumes
Desktopif none is found (which is common). ; The actual .jkm layout name is
the found name plus " Keys." let layoutBase = iniReadString("options",
"KeyboardType", "Desktop", jdir+"user.ini") let layouts = layoutBase +"
Keys"; Now get the name of the extra section to use for this layout. ; This
is listed in [Keyboard Layouts] in default.jkm. ; Example key/value line:
Desktop=Common. ; This has always been Common, but we look just to be safe.
;TODO: It might be possible to link multiple layouts here. let layoutBase =
iniReadString("Keyboard Layouts", layoutBase, "Common", jsdir+"default.jkm")
let layouts = layouts +"|" +layoutBase +" Keys" ; That's it for the
keyboard;now for the Braille display... ; First find out if we have one
active. if !brailleInUse() then return layouts endIf ; Find out which
Brailledisplay is supposed to be active. ; This comes from [options] in
default.jcf. ; Example: BrailleDisplay=Braille1. ; This seems to be set even
when there isn't a Braille display. ; "Name" is appended to make the actual
jfw.ini key to search for below. let temp = iniReadString("options",
"BrailleDisplay", "", jsdir+"default.jcf") if !temp then return layouts
endIflet temp = temp +"Name" ; Get the device name for the Braille display.
;This comes from [BrailleDisplays] in jfw.ini. ; Example:
Braille1Name=TPLite. let temp = iniReadString("BrailleDisplays", temp, "",
jdir+"jfw.ini") if temp then let layouts = layouts +"|" +temp +" Keys" endIf
return layouts endFunction string function kl_getScriptList(string
appBaseName) ; Gets and returns a list of unique script names referenced by
the .jkm file for the indicated application. var string jkmname, string
sects, string sect, string scriptList let jkmname =
getJAWSSettingsDirectory() +"\\" +appBaseName +".jkm" let sects =
kl_getSectNames() while True let sect = kl_stringSegmentNext(sects, "|") if
sect then kl_readKeySection(jkmname, sect, scriptList) else return
scriptListendIf endWhile ; line never reached endFunction object function
createObjectEx(string objname, int f) ; Permits this module to compile under
JAWS versions earlier than JAWS 5.00.621. ; TODO: a kludge. return
createObjectEx(objname, f) endFunction object function kl_getDocObject() ;
Creates and returns an HTML document object with no content. var string
objname, object o, object oDoc let objname = "InternetExplorer.Application"
;Use CreateObject, not GetObject, so we always get a new one. let o =
createObject(objname) if !o &&getJFWVersion() >= 500619 then ; Try forcing
use of CoCreateInstance (may help when JAWS is running as a service) let o =
createObjectEx(objname, False) ;if o then sayString("Used CreateObjectEx")
endIf ; TODO: remove. endIf if !o then return 0 endIf ; Initialize the
objectfor use, and get an actual document object. let o.visible = 0
o.navigate("about:blank"[2]) let oDoc = o.document let o.visible = 1 ;
Returnthe document object, not the root object. return oDoc endFunction int
function kl_writeLine(object oDoc, string text) return oDoc.write(text)
endFunction int function kl_writeHeadFoot(object oDoc, string title) ;
Handles the header and footer of a document. ; The header is written if
titleis non-null, otherwise the footer is written. ; NOTE: This function
currently includes an embedded STYLE section drawn from the author's
documenttemplate. if title then kl_writeLine(oDoc, "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.0 Transitional//EN\">") kl_writeLine(oDoc,
"<HTML><HEAD>") kl_writeLine(oDoc, "<!--") kl_writeLine(oDoc, "<style
type=\"text/css\">") kl_writeLine(oDoc, "td {") kl_writeLine(oDoc, "
vertical-align: top;") kl_writeLine(oDoc, "}") kl_writeLine(oDoc,
"</style>")kl_writeLine(oDoc, "-->") kl_writeLine(oDoc, "<TITLE>" +title
+"</TITLE>") kl_writeLine(oDoc, "</HEAD><BODY>") kl_writeLine(oDoc, "<H1>"
+title +"</H1>") else kl_writeLine(oDoc, "</BODY></HTML>") endIf return True
endFunction int function kl_writeTable(object oDoc, int starting) ; Writes
the HTML for the start/end of a table. if starting then kl_writeLine(oDoc,
"<TABLE border=1 cellSpacing=0 cellPadding=0>") else kl_writeLine(oDoc,
"</TABLE>") endIf endFunction int function kl_writeRow(object oDoc, int
isHeader, string scriptName, string keyList, string syn, string desc) ;
Writes a row of the table generated by this module. var string t1, string t2
if isHeader then let t1 = "<TH>" let t2 = "</TH>" else let t1 = "<TD>" let
t2= "</TD>" endIf kl_writeLine(oDoc, "") kl_writeLine(oDoc, "<TR>")
kl_writeLine(oDoc, t1+scriptName+t2) kl_writeLine(oDoc, t1+keyList+t2)
kl_writeLine(oDoc, t1+syn+t2) kl_writeLine(oDoc, t1+desc+t2)
kl_writeLine(oDoc, "</TR>") return True endFunction int function
klShowKeyBindings(string appBaseName) ; Shows a list of all key bindings
effective in the indicated application. ; If appBaseName is "default," the
default key bindings are shown. ; If appBaseName is empty, the current one
(determined via GetActiveConfiguration) is used. ; If getActiveConfiguration
fails, getScriptFileName is used. var object oDoc, string scriptList, string
scriptName, int done if getJFWVersion() <500000 then sayMessage(OT_Message,
"This function requires JAWS 5.00 or above.") return False endIf if
!appBaseName then let appBaseName = getActiveConfiguration() endIf ; In case
getActiveConfiguration() fails (seen at least in older JAWS versions) if
!appBaseName then let appBaseName = getScriptFileName(True) if
stringContains(appBaseName, ".jsb") then let appBaseName =
stringChopRight(appBaseName, 4) endIf endIf sayMessage(OT_Message, "Building
command list") let scriptList = kl_getScriptList(appBaseName) if !scriptList
then sayMessage(OT_Message, "No special JAWS commands found for "
+appBaseName) return False endIf let oDoc = kl_getDocObject() if !oDoc then
sayMessage(OT_Message, "Failed to get a document object") return False endIf
kl_writeHeadFoot(oDoc, "JAWS Scripts and Keystrokes For " +appBaseName)
kl_writeTable(oDoc, True) kl_writeRow(oDoc, True, "Script", "Key(s)",
"Synopsis", "Description") let done = False while !done let scriptName =
kl_stringSegmentNext(scriptList, "|") if scriptName then kl_writeRow(oDoc,
False, scriptName, getScriptKeyNames(scriptName),
getScriptSynopsis(scriptName), getScriptDescription(scriptName)) else let
done = True endIf endWhile kl_writeTable(oDoc, False) kl_writeHeadFoot(oDoc,
"") ; The document will display itself (probably already has). return True
endFunction ; EndModule
;***********************************************************************
-------------------- Cut Here --------------------
--- Links ---
1 mailto:doug@xxxxxxxxxxxx
2 about:blank
__________
Visit and contribute to The JAWS Script Repository http://jawsscripts.com
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
Other related posts: