Preventing Chrome from closing with JAWS scripting

One of my pet peeves while using Chrome is when I’m listening to something in a browser tab, working in another one and then decide to close the current one. I press Alt+F4 instead of control F4 and my audio stream is interrupted.

Sure, you can relaunch Chrome and then press Control+Shift+t to regain all of your tabs, but you still have to find your spot in the audio stream.

Well, I’ve devised a little JAWS script and figured I’d share it here.  Yes, I know that Edge has this built-in to their browser, but I tend to like Chrome

better… and I like tinkering with code.

So here are the steps:

  1. Launch the JAWS script editor while you’re in a Chrome window with Insert+0 on the number row.
  2. Press control+end to get to the bottom of the script file.
  3. Press Control+E to create a new script.
  4. Type in a name for the script, something like PreventsClosing and press Tab. Note, this edit box does not accept spaces, so use capitals if you like.
  5. Check the  box that says: Can be attached to key, and press Tab.
  6. Type in what ever you want in the Description and Synopsis edit boxes.
  7. Tab through to the Assign to hotkey area.  Press Alt+F4. The window won’t close on you.  Instead the key sequence will be copied to this field.
  8. Tab to okay and press Enter.
  9. Now you are ready to copy the code below:

int button
button = ExMessageBox (“ARE you sure?”, “Close Chrome”, MB_YESNO|MB_DEFBUTTON1)
if button == 6

Once you copied the above code, press control+s and the script will be compiled.
Press Alt+f4 to close.
You can now test your modifications by pressing Alt+f4 in Chrome.
A message window will popup asking you if you really want to close Chrome.
Press Enter on yes and it will proceed.  Otherwise, choosing the no button will keep you in Chrome.




About mcourcel

I work within the Information Technology industry. More precisely, within the accessibility field. Oddly enough, I'm trying out WordPress to evaluate its ease of use and just to tinker with various topics of my choosing.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s