One of the things I like when I’m testing web pages is efficiency. I also like to minimize key presses and procedures of loading and unloading programs. In particular, bouncing back and forth between JAWS and NVDA. So, with the help of AutoHotkey and a few lines of JAWS scripting, I managed to create a screen reader toggle key. Now every time I press Control+F12, it unloads the current screen reader and loads the other one. What follows is how to set this up on your own system. It takes a few steps and a bit of know-how, but once it’s set, it’s pretty darn sweet.
Setting up JAWS
First thing is to create the shortcut key/script to unload JAWS. Yep, you’re going to make a JAWS script. It’s actually not too difficult and I’ll walk you through it. Let’s get to the JAWS script editor by pressing Insert+0; that’s the 0 on your main keyboard, not the number pad.
Next you’ll have to make sure that you’re in the Default script file by pressing CONTROL+SHIFT+D
Still with me? Good. Now press control+End to get to the bottom of this script file.
Next, press Control+E to create a new script.
This is essentially a form to gather information for your new script that you navigate with the Tab and Shift+Tab keys. The first field that you land on is the script name. I called mine Kill JAWS, but you can name it whatever you want.
The following field is a checkbox which you’ll need to check, as you want to connect this script to a shortcut key.
The neighboring 3 fields are: Description, Synopsis and Category. JAWS uses these fields to incorporate into the help system. You can put whatever you want in there. Or just leave them blank.
The last field is labeled “Assign to”. This is where you designate your shortcut key. I used Control+F12, but you can use whatever key combination that you like. Just press the key combination and it will populate the field with the text equivalent. If the shortcut is already in use, JAWS will warn you and you’ll have to choose something else.
Finally, your next tab press will bring you to Ok. Activate it and let’s get to the fun stuff.
You are now brought back to an editing window. Your cursor is located between the script name and the “EndScript” command. This is where you will copy and paste the 3 lines below. I will explain what they do following the lines of code.
Run (“nvda”)
shutDownJAWS()
pause()
The first line runs NVDA. No need to give it a path, unless you have it installed as a portable version. Otherwise, you’ll need to explicitly point to its location.
The second line actually calls another script named shutDownJAWS() Oddly enough, it does exactly that.
The final line tells JAWS to wait (or pause) for a moment. Depending on your PC speed, you may have to add a few of these lines.
Okay, so we’re done this part. Now, let’s save your work by pressing Control+S. If all is well in the world of Jaws scripting, the script will be compiled, JAWS will say: compile complete and you’re set.
If you get an “unexpected run command encountered”, you’ll need to edit the NVDA line. Erase and retype the quotes.
Thanks to StickBear for these modifications/suggestions.
Now close the scripting window with Alt+F4 and let’s try your new script.
Just make sure you have a way of running JAWS again, or you might find yourself with a very quiet computer. Control+Alt+J usually does the trick. If not, Press Windows+r to execute the run command, type in JAWS and the version number. For example, JAWS2020. Then press Enter and it should load up.
Congrats, you’ve made your first JAWS script.
Integrating Autohotkey
AutoHotkey has been around for years. It’s a powerful, easy to use, shortcut key creator and script automator; is that even a word? Anyway, you’ll be using this tool to Unload NVDA, and load JAWS back into memory.
Let’s go find AutoHotkey. You can find it at this link:
http://www.autohotkey.com
Spend some time on the main page to see examples of what Autohotkey can do.
I’m not going through the download and Install process, but I would recommend downloading the current version, so we’re all on the same page.
Once installed, Autohotkey runs in the background and will have a system tray icon. We’re going to go find that icon, activate it and get into the menu.
Press Windows+D to get to the desktop.
Shift+Tab until you get to the System Tray Icons. Once there you can navigate these icons with the arrow keys. You’ll be looking for an icon that reads: “settings.ahk”, or something similar. The .ahk file extension is reserved for any AutoHotkey script files. Once there, press either the applications key, or Shift+F10. This will bring up the AutoHotkey menu. Arrow down to “Edit ThisScript” and press Enter.
Notepad will load up and we can now edit our NVDA to JAWS transition script. Copy the lines below into that script. I’ll explain each line’s function after the code below.
^f12::
Run c:\progra~2\nvda\nvda.exe -q
Sleep 10
Run jaws2020
Return
The first line designates the shortcut key, which in my case is Control+F12. The caret sign represents the control key. Number sign # is for the Windows key. The Exclamation point ! is for Alt and the plus sign + is for the Shift key. You can find more info On AutoHotkey bindings here:
https://www.autohotkey.com/docs/Hotkeys.htm
Back to our line description. Following the caret symbol is the designated key, which in my case is F12. The 2 colons following the key designator tells AutoHotkey that this is a shortcut and it also indicates the start of a new script.
The next line in our script tells NVDA to shutdown. This is done with the /q commandline switch.
This will only work if you installed NVDA in its default folder. Otherwise, you’ll have to modify this line.
Also note, you don’t’ need to double the backslashes for commands in AutoHotkey scripts.
The Sleep command pauses the script for a user-defined time; in this case 10 milliseconds. You may need to tinker with this if things don’t work properly.
The second last line runs JAWS. This line will have to be updated when ever you go up a major version.
Finally, the Return command signals to AutoHotkey that the script is complete.
Once you’re done editing the script, press Control+S to save your work and Alt+F4 to get out of Notepad.
Final step is to go back to your Desktop With Windows+D, Shift+tab until you get to the system tray, go find the AutoHotkey settings.ahk icon and activate the menu with Shift+F10. Arrow down to the “Reload This Script” option and press Enter.
You are now in business. Press your previously created shortcut key and it should unload the currently running screen reader and load the other one. This setup doesn’t care which screen reader is loaded first. At any rate, there you have it; a fully automated screen reader toggling shortcut key.
Further Reading and Resources
AutoHotkey Documentation: https://www.autohotkey.com/docs/AutoHotkey.htm
JAWS scripting, from Freedom Scientific: https://bit.ly/2X4Y2mc