AutoHotkey Tip of the Week: Add Temporary Hotkeys to MsgBox Windows—September 23, 2019

Isolate Hotkeys to Only Operate for an Open or Active Window

In the Weekly Tip, “IfWinActive Versus #IfWinActive“, I recommended isolating Hotkeys to specific windows. This time I offer a practical example.

hotkeycover200For more information, see “Chapter Two: Block Windows Shortcuts with AutoHotkey” and “Chapter Three: AutoHotkey #Directives for Context-Sensitive Hotkeys—#IfWinActive” of the book AutoHotkey Hotkey Tips, Tricks, and Techniques.

The #IfWinExist directive offers a number of advantages when creating temporary Hotkeys:

  1. The Hotkeys activate only when AutoHotkey opens the controlling window.
  2. If other conflicting Hotkeys exist, the temporary Hotkeys take precedence as long as the window exists.
  3. After closing the controlling window, the Hotkeys deactivate minimizing interference with other possible Hotkeys or shortcuts.

Continue reading

AutoHotkey Tip of the Week: Auto-Swap Transposed Letters—September 9, 2019

Tip: Fix Reversed Letter Typos with this Simple Hotkey Trick

SwapLetters
Place the cursor between two letters and hit the Alt+R Hotkey combination. The letters reverse positions.

Light Bulb!I use this Hotkey whenever my mild dyslexia kicks in and leaves me with swapped letters. My AutoHotkey AutoCorrect.ahk script may catch many such errors but many more make it on to my computer screen. I could have written a Hotkey routine which swapped pre-selected (highlighted) letters, but, rather than taking the time to select the characters by dragging the mouse across them, I wanted to merely place the cursor between the two errant letters.

This use of the Send command makes it incredibly easy to transpose any two letters. Simply place the cursor between them and hit ALT+R (as shown in the figure.)

Continue reading

AutoHotkey Tip of the Week: Instant Upper Case, Lower Case, and Initial Cap Text—September 2, 2019

Tips: Quick Hotkeys for Changing Text To/From Capital Letters and How to Initial Cap Everything, Plus, How to Write Robust Clipboard Routines

Light Bulb!This week I offer two useful tips: one for editing text and the other for improving your AutoHotkey scripts.

When reviewing my books, I look for those tips which I use all the time. I’ve found that I developed some scripts primarily for demonstration purposes and rarely ever use them again. Yet, I have a few which I use so much that I feel like they have become a part of my Windows system.

AHKNewCover200In this case, while perusing my Beginner’s Guide to AutoHotkey, I noticed in “Chapter Four: Hotkeys and Text Editing with Windows Clipboard” the Hotkeys for changing selected portions of text into all capital letters, all lowercase letters, or initial cap every word in the section. I originally wrote these Hotkeys when I edited articles submitted by freelance writers.

Some writers have a penchant for placing their article headlines and topic subheadings in all uppercase letters. By creating a Hotkey for converting the entire line to Title Mode (initial capital letter for each word), I quickly solved the retyping problem:
Continue reading

Adding Italics to Hotstrings in Word Processing Software (AutoHotkey Quick Tip)

If You Work with a Word Processing Program (Local or Web-Based) Which Supports Control Characters for Special Formatting, Then, Possibly, You Can Add Auto-Italics (or Bold, Underline, Etc.) to Your Autohotkey Hotstrings

A little while back, I wrote the blog “Italicize Your Hotstring Replacements with this Input Command Ploy (AutoHotkey Tip)” which demonstrated tricks for adding special features robotaicartoonfor both the Input command and Hotstrings. While clever solutions (possibly too clever), I now realized that in many programs (and Web apps), there might exist a much easier solution—a “duh” moment. Continue reading

Pressing GUI Buttons with a Single Keystroke (AutoHotkey Tip)

Sometimes We Find It Easier to Hit a Key Rather Than Click a Button

An AutoHotkey forum user posted a question about using Hotkeys to activate buttons in a GUI window. He wanted to hit the numbers 1, 2, 3, or 4, rather than clicking the individual buttons—but only for the active GUI window.

hotkeycover200While I discuss similar isolation of Hotkeys to specific active windows in my Hotkeys book, this blog provided another opportunity to show how to add more functionality to your GUIs without infringing upon other programs or Hotkeys. I attempted to make the script as simple as possible by using a number of AutoHotkey tricks. Continue reading

A Trick for Inserting Next Friday’s Date into Any Document (AutoHotkey Tip)

An AutoHotkey Technique for Determining Date for Any Coming Day of the Week, Plus a Pop-up for Picking Future Weekdays

“Do You Know Next Friday’s Date?”

We record upcoming events on our monthly calendars, but we live one week at a time. Most people work Monday through Friday and relax on Saturday and Sunday. If someone gives us a date for an occasion, we ask, “What day is that?”—meaning “Give me the day of the week.”

Continue reading

Swapping Dyslexic Letters (A Favorite AutoHotkey Trick)

Sometimes the Little Things Remind Me How Much I Like AutoHotkey

As I worked on one of my blogs, I accidentally transposed two letters (probably “form” for “from” or vice versa). I placed the cursor between the errant letters and hit the R key while holding down ALT. The two characters exchanged position. Pleased with myself, I decided to highlight the letter-swapping Hotkey combination in this blog as one of my favorites.

Continue reading

The Main Window for Debugging AutoHotkey Scripts

How to View the Inner Workings and Hidden Mechanisms of Running AutoHotkey Scripts

AutoHotkey includes a tool called the Main Window which aids with the debugging process. It gives you a peek into various aspects of a running .ahk script:

  1. Most recently executed lines of code (ListLines command).
  2. Current variables and values (ListVars command).
  3. Active Hotkeys (ListHotkeys command).
  4. Keyboard activity (KeyHistory command).

Main Window Menu

Open the Main Window by right-clicking on Windows System Tray icon of an active .ahk script and selecting Open from the top of the menu. The window pops open at the “Lines most recently executed” view. You can select the other three views plus “Refresh” from the View menu. Continue reading

Beginning Tips for Writing AutoHotkey Scripts

Exploring the Existential Mysteries of AutoHotkey Code and How It’s Often Misunderstood

AutoHotkeyInsightsI’ve just published my latest book, Beginning Tips for Writing AutoHotkey Script, which endeavors to clear up some of the mystery surrounding the way AutoHotkey works. You’ll find grasping how AutoHotkey processes AHK scripts a tremendous help. Quite a bit of the confusion encountered by novice AutoHotkey scriptwriters occurs through misunderstandings about the manner in which everything (life, the universe, and AutoHotkey scripts) fits together. I wrote the book with that muddiness in mind. Continue reading

Matching Instant Hotkeys with a Loop (AutoHotkey Tip)

Sometimes You’ll Find a Loop a Simpler Way to Match Things

ProgrammingRobot

“…stuck in an infinite loop. Like I just said, it’s so depressing to get stuck in an infinite loop. Like I just said, it’s…”

If you’re new to AutoHotkey with little or no scripting experience, then this blog may venture too far into the weeds. I don’t like to put off new users because the journey into Windows scripting is well worthwhile. Most find it easy to get started with AutoHotkey with many simple-to-implement tools. However, it takes a little time to understand the nuances of the more advanced techniques. I recommend that AutoHotkey noobies start with the basics such as found in the “Introduction to AutoHotkey: A Review and Guide for Beginners” page. You’ll obtain immediate, rewarding results with basic AutoHotkey. Then, as your comfort with scripting increases, introduce yourself to more of AutoHotkey’s power with some of the slightly elevated topics.

*          *          *

In the last blog, by writing the IH_VarText(Var) function, I created a clever (even if I do say so myself) yet uneasy technique for linking the Instant Hotkey combination to the insertion text by converting the key combination (full of illegal variable characters) to a legal two-deep variable. While this worked, in most cases, it left a number of holes in the subroutine. Unless I added a trap line for every possible illegal key (e.g. the semicolon ” ; “ key, the slash ” / ” key, the hyphen ” ‘ ” key, etc), errors might occur. I needed to make a change. Continue reading