[jawsscripts] Re: Keyboard help

  • From: "Steve Spamer" <stevespamer68@xxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Sun, 7 Oct 2018 14:59:27 +0100

Udo, like I say your help is invaluable, along with all the other members of 
this list.
The situation I'm at at the moment, is I reverted back to copying out the 
default keybaord help functions and modifying them to work as I want.  All 
is well and exactly what is needed, but just need to add the script keys 
within the default KeyboardHelpHook function I've copied.

BTW, I did change the trap keys function to both true, true and true, false, 
but this still didn't stop an app key from getting through, however, it did 
allow keys like alt etc to get through.  I need to definitely do more 
reading iand will hopefully get around to that soon.  In the meantime, 
thanks again for your support and help. THX Steve.

-----Original Message----- 
From: Udo Egner-Walter
Sent: Sunday, October 7, 2018 2:16 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Keyboard help

Hi Steve,

in the example I used TrapKeys (True, False). That means the TrapKey is
on (= first parameter) and TrapKey should not ignore system keys (=
second parameter).

In the FSDN you can read:

Param 2:
Type: Int
Description: TRUE to enable trapping of keystrokes used in combination
with delayed modifier keys. Set to FALSE, for example, if you want
system keys such as Alt to be sent through to the system, even though
trap keys is enabled.
Include: Optional

The reason I used "false" here is: If you use "true" you can't switch to
other application with Alt+Tab. If you use "False" you can switch with
Alt+Tab to JAWS and shut it down if something went wrong.

You can try "true" and decide if this suit your needs. But If you don't
have a key attached to a script for disable TrapKeys you might swear a
lot ;-)

And by the way: I'm glad if I can help. I recall my first JAWS script
experience and was always happy if someone gave me a hint. And this is
why are such mailing groups exists: you can often find someone to help.
In this sense: keep on scripting, have a lot of fun and if I can help, I
do my best ...

Best wishes

Udo





Am 07.10.2018 um 14:44 schrieb Steve Spamer:
Hi Udo.  I've tried the trap keys method and I'm still having unscripted
keys (application default/unscripted keys) executed.  Apart from that it
works great.
I'll try the hook method and see if this makes any difference, as I
basically want it to work the same way the default keyboard help works.
This doesn't allow any unscripted key to be exacuted The trap keys method
seems to me as if all possible combinations have to be specified, rather
than just saying something like:
; if a script is associated with a keystroke
If IsScriptedKey() Then
; run the script, as the script is only speaking a message
Else
    ; if it's not a script, it's a native app key
Do nothing and just announce the key
EndIf

That seems to simplistic I know lol, but I would have thought this was
possible.  Specifying all script keys seems pretty overkill....but I know
things are never that straight forward <grin. THX Steve.
-----Original Message-----
From: Udo Egner-Walter
Sent: Sunday, October 7, 2018 9:41 AM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Keyboard help

Hi Steve,

you don't need a hook necessarily. You can use TrapKey only for getting
control of the keys. For example:

<begin code>

; assign a shortcut to StartTrap to begin the trapping

Script StartTrap ()

TrapKeys (True, False)

EndScript

; end the trapping either by assigning a shortcut or by pressing ESC
(see ProcesskeyPressed)

Script EndTrap ()

TrapKeys (False)

EndScript


; here is the checking of the keys

Void Function ProcessKeyPressed (int iKeyCode, string sKeyName, int
IsBraille, int IsScriptKey)

; react on pressing F1

If sKeyName == "F1" then

SayString ("You pressed F1")

EndIf

; other keys ...


; End the trapping

If sKeyName == "ESCAPE" Then

PerformScript EndTrap ()

EndIf

; pass the function to other scripts

ProcessKeyPressed (iKeyCode, sKeyName, IsBraille, IsScriptKey)

EndFunction

<end code>


By the way if you need to process you own scripts, you can use the hook
too. For example:

<begin code>

; assign a shortcut to start trapping and the hook

Script StartHook ()

; Start hook function "MyHook"

AddHook (HK_SCRIPT, "MyHook")

; trap the keys

TrapKeys (True, False)

EndScript

; end the hook either by assigning a shortcut or by pressing ESC (see
ProcessKeyPressed)

Script EndHook ()

; no more trapping

TrapKeys (False)

; remove the hook

RemoveHook (HK_SCRIPT, "MyHook")

EndScript


; in the hook function you can decide which script to run

void Function MyHook (string sScriptname)

; if the script name is "YourScriptName" then

if sScriptName == "YourScriptName" then

      ; allow execution

      return True

endIf


; if you want to end the hook you should allow EndHook to run

if sScriptName == "EndHook" then

      ; allow execution

      return True

endIf

; no execution for other scripts

Return False

EndFunction


; Check for key pressing

Void Function ProcessKeyPressed (int iKeyCode, string sKeyName, int
IsBraille, int IsScriptKey)

; If F1 is pressed


If sKeyName == "F1" then

; execute your script

PerformScript YourScriptName ()

EndIf

; If ESC is pressed

If sKeyName == "ESCAPE" Then

; unhook and don't trap keys

PerformScript EndHook ()

EndIf

; pass event to other scripts

ProcessKeyPressed (iKeyCode, sKeyName, IsBraille, IsScriptKey)

EndFunction

<end code>


But be careful: the hook is still running if you switch to other
application so it's a good idea of releasing it in the AutoFinishEvent.

Hope this helps and good luck for your app

Udo



Am 06.10.2018 um 23:53 schrieb Steve Spamer:
Hi, thanks so much. I'll take a fresher look at this tomorrow, as I feel
I'm
nearly there.  I've currently just copied across the keyboard help,
KeyboardHelpHook and UnhookKeybaordHelp to my scripts.  I can add my own
scripts to speak in the Keyboard HelpHook function, but stopping non
scripted keys are still getting through.  I'm missing something, but
hopefully I'll see it with a refreshed brain :).  Thanks again. Steve.

-----Original Message-----
From: Udo Egner-Walter
Sent: Saturday, October 6, 2018 7:07 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Keyboard help

Hi Steve,

I'm not sure if I understand you.

If you install a hook in your application, for example

AddHook (HK_SCRIPT, "MyHook")

then inside the hook function "MyHook" you can allow a script to be
executed or not. All scripts had to pass the function and you alone
decide which scripts to execute.

If you further trap the keys with the TrapKeys function then the keys
were not sent to the application.

In the KeyPressedEvent of you application (or the like) the keys are
still arriving. So here you can decide what to do (for example start
your own script, end the hook and so on).

But please remember to uninstall the hook at the end. Otherwise the
default scripts are not running any more.

Hope this helps a little

Udo



Am 06.10.2018 um 19:36 schrieb Steve Spamer:
Hi, a question on Jaws keyboard help.

I currently have a working solution that allows a user to turn on
keyboard
help and get descriptions of specific keys in any particular window. 
All
of
this information is in a set of scripts that you switch to when pressing
jaws key plus 1.  It maybe not the most elegant solution, as it still
allows
any undocumented keys to be processed by the application.

So, looking at the Jaws help, I'm wondering if anyone knows if the
default
script could be modified to access the assigned keys I have, while
ignoring
any other key, so not letting it be processed.  The lines of interest in
the
default jaws cripts are I think:

AddHook (HK_SCRIPT, "KeyboardHelpHook")
; ignore any keys not attached to scripts
TrapKeys(TRUE)
CaptureAllGestures(TRUE)

The line:
AddHook (HK_SCRIPT, "KeyboardHelpHook")
looks to me as if this "KeyboardHelpHook" is where the information is
taken
from.  Of course I am probably totally wrong, but if I could find this,
it
may give me clues to what to do.  Otherwise, is there a way to use this
default script, but use information/keys I have in a set of scripts/ jkm
files etc.

THX Steve.

Follow me on Twitter: @stevesax123
Visit the samplitude Access website. Jaws scripts for pro recording with
Samplitude in Windows: www.samplitudeaccess.org.uk

__________�

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

__________�

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

__________�

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

__________�

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

__________�

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


__________�

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

__________�

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

Other related posts: