Replacing Overused Words with Pop-up Synonym Menus, (Part 7, Beginning Hotstrings)

Whether You’re a Student or Merely Want to Improve Your Writing, Use Hotstring Menus to Insert Substitutes for Over Abused Words…Plus Another Free AutoHotkey Script!

*          *          *

New to AutoHotkey? See “Introduction to AutoHotkey: A Review and Guide for Beginners.”

*          *          *

As a convenience for people who want to get this entire series (plus more) in one place, I have now published the e-book Beginning AutoHotkey Hotstrings which is available on the ComputorEdge E-Books site (in three formats—EPUB for mobile devices, MOBI for Kindle, and PDF for printing and computer) and through Amazon. Regardless of whether you’re interested in the book or not, it’s worth your time to peruse some of the blogs linked at “Beginning AutoHotkey Hotstring Techniques” found under the “AutoHotkey Topics and Series” tab in the top menu bar. They just might inspire your next AutoHotkey script.

Beginning AutoHotkey Hotstrings 200pxAs a convenience for people who want to get this entire series (plus more) in one place, I have now published the e-book Beginning AutoHotkey Hotstrings which is available on the ComputorEdge E-Books site (in three formats—EPUB for mobile devices, MOBI for Kindle, and PDF for printing and computer) and through Amazon. Regardless of whether you’re interested in the book or not, it’s worth your time to peruse some of the blogs linked at “Beginning AutoHotkey Hotstring Techniques” found under the “AutoHotkey Topics and Series” tab in the top menu bar. They just might inspire your next AutoHotkey script.

*          *          *

When I first started working on this topic, I only planned to demonstrate a slightly different way to employ the Hotstring menus previously discussed in this series on AutoHotkey Hotstrings. But as I found various Web sites offering lists of overused and abused English words, I realized that I was developing an AutoHotkey app which might benefit anyone who’s trying to improve their writing.

This simple AutoHotkey script which I call OverusedWords.ahk is probably not for uninterrupted use since too many pop-ups might drive you crazy. However, for anyone who desires to improve their writing skills, this easy little app might be just the ticket. (The script can be downloaded from the ComputorEdge AutoHotkey script site. All the scripts available at the site are discussed at the Web page “Free AutoHotkey Scripts and Apps for Learning Script Writing and Generating Ideas.”)

The script starts with a list of less than 100 words noted over the years by English teachers as commonly overused in papers and compositions. You can easily modify the script by adding more of your pet peeves or other possible replacement words. Whenever you type one of those keywords, a menu pops up with a list of recommendations. If none fit the context of your usage, then hit the Escape key and continue on. This script is not designed to be the endall in synonym lists, but rather a technique which affects how you consider the words you use. Reviewing the lists as they pop-up forces you to reflect on which might be your best choice of words.

I expect that people will modify the OverusedWords.ahk script to suit their particular needs. I’m not convinced that the included starter list is the best choice of words nor that the selection options are optimal. It will take some time to find what will work best for me. Nevertheless, that’s the purpose and power of AutoHotkey. This script can be easily changed for use with any type of jargon or vernacular.

*         *          *

When writing, it’s important to avoid the use of the same words over and over again. Otherwise, people will get bored and assume that you have a limited vocabulary. One way to deal with the problem is by looking up synonyms whenever you notice you’re overusing a particular term. That works great, but the procedure takes a little time. Wouldn’t it be easier if tailored Hotstring menus with replacement words popped up whenever you typed an abused word?

There are too many synonyms in English to build a menu for each one—at least not without great effort and a more complex AutoHotkey algorithm than the one offered here. Nevertheless, I found this list of Synonyms For Words Commonly Used In Student’s Writings. It’s a good start for anyone desiring to improve their writing. Plus, if particular words keep cropping up in your endeavors, you can always add new menus.

The New Hotstring Menu Function

In previous blogs we developed a function which builds a pop-up selection menu from a list of words. This time by making a couple of changes in the function and Hotstring options, a list of alternatives words pops up and only deletes the original word after a menu selection. Hitting ESC closes the menu without any damage.

To make this AutoHotkey technique work, there are two requirements:

  1. The original word must not be deleted unless selecting an alternative.
  2. The menu should appear only when pressing one designated terminating character (in this case the Spacebar).
But pop-up
After typing the word “but” followed by the Spacebar, a menu of alternatives pops up.

In the following example I use the word but as the abused text—even though it doesn’t appear in the referenced list. When writing people commonly reuse but when there are numerous alternatives as shown in the image at right.

I went to the store, but it was closed. But, the sign said that it should be open. But when I talked to a friend, he said that it was open when he was there. I would stop going to that store, but it is the only one which carries the candy bars I like.

I went to the store, but it was closed. Yet, the sign said that it should be open. All the same, when I talked to a friend, he said that it was open when he was there. I would stop going to that store, although it is the only one which carries the candy bars I like.

By using a quickly accessible Hotstring menu, it’s easy to substitute a more appropriate word or phrase. The following Hotstring calls up the menu for the word but :

:B0:but::
  If A_EndChar = %A_Space%
    WordMenu(4,"nevertheless,nonetheless,however,still
      ,yet,though,although,even so,for all that
      ,despite that,in spite of that,anyway,anyhow
      ,be that as it may,all the same,having said that
      ,notwithstanding")
Return

Note: For display purposes Line Continuation is used to wrap the list of alternative words. By starting a line with the comma as shown above, AutoHotkey assumes that the line is continued from and part of the previous line.

Using the B0 option in the Hotstring (:B0:but::) ensures that the activating word will not be automatically deleted (backspaced). If after the menu appears you decide to keep the original word. merely hit the ESC key or mouse click off the menu. The deletion only occurs if a selection is made.

This Hotstring only triggers if the activating character is a space (If A_EndChar = %A_Space%). I used the space character because it forces the pop-up open most times the word but is used in regular typing. If you’re afraid that this firing may occur too often and get annoying, then you can use another character, such as the backslash \. However, if you change the end character to a more obscure puntuation, you are less likely to notice that you’re using the word but way too much. (Want to keep the but? Just hit ESC.)

ComputorEdge AutoHotkey E-Books

Note: In the script OverusedWords.ahk I’ve added the variable LastChar. By changing the value of LastChar, the terminating character can be changed for all the overused words.

I’ve changed the name of the Hotstring menu function to WordMenu(). This limits the possible confusion (and probable conflict) with earlier versions of the Hotstring menu function. The major change in the new function involves the addition of a second parameter—which I called Spaces. The parameter Spaces passes the number of places of backspacing needed in order to delete the old word before replacing it with a new one. In this case, the number is four—the length of the Hotstring text but (3) plus the ending character (1).

If the end character is a space, then the function WordMenu() runs. Otherwise, nothing interferes and you can continue typing. There are a couple of changes in the menu function from previous blogs as shown:

WordMenu(Spaces,TextOptions)
 {
   Global BackSpaces
   BackSpaces := Spaces
   StringSplit, MenuItems, TextOptions , `,
   Loop %MenuItems0%
   {
     Item := MenuItems%A_Index%
     Menu, MyMenu, add, %Item%, WordMenuAction
   }
   Menu, MyMenu, Show
   Menu, MyMenu, DeleteAll
 }

The Spaces parameter is added to the function to pass the number of backspaces required to delete the old word…after a selection is executed.

The Global command (Global BackSpaces) is added to define a variable which can be used anywhere in the script. Remember that variables created inside a function are local and only available while the function is running. Global makes the variable ready for use everywhere. Creating a global value for Spaces is essential since it is not used for deleting the old word until after the function has run and a selection is made.

The value of the passed parameter Spaces is stored to Backspaces—making the number of backspaces available throughout the script.

The remainder of the function stays the same as discussed in previous blogs.

Make a selection from the menu and the Label subroutine WordMenuAction: executes. This modified subroutine includes the necessary backspacing to delete the original word:

WordMenuAction:
 SendInput {BackSpace %BackSpaces%}
 SendInput %A_ThisMenuItem%{raw}%A_EndChar%
Return

Building an Overused Word App

I’ve compiled a script with the abused words listed at the reference Web site. The script OverusedWords.ahk, plus a compiled version OverusedWords.exe are included in the ZIP file OverusedWords.zip and available at the ComputorEdge AutoHotkey script site. There are a few differences in the posted script which I will discuss next time.

*         *          *

Find Jack’s AutoHotkey e-Books at ComputorEdgeBooks.com.

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s