Quick Tip: Using the Sleep Command with Clipboard Routines

Use the Sleep Command to Debug Intermittent Routines

tipsLast night, I received the following comment from Thom Blake about last week’s blog “Auto-Capitalize the First Letter of Sentences” prompting this Quick Tip about adding the Sleep command at critical points in certain types of AutoHotkey routines:

Jack

Great script but I seem to have a problem with the capitalize a word function. It only works intermittently. The message box says “No text selected!” when clearly there is.

Thanks, Thom!

This is a needed reminder about a common problem when using the Send command with the Clipboard routine. Sometimes, for whatever reason, certain commands execute before the completion of the last action. In this case, AutoHotkey attempts to copy text to the Windows Clipboard before the SendInput text selection action completes: Continue reading

AutoHotkey Tip of the Week: Auto-Capitalize the First Letter of Sentences

Some People Don’t Find It Easy to Shift to Uppercase While Capitalizing Words—AutoHotkey Allows Us to Stop Reaching for the Shift Key—at Least for New Sentences!

I received the following question from a reader:

Hello,

Is there a script to auto-capitalize the first word of a sentence. Or after a period?

Thanks.

*          *          *

Not everyone received an A in typing class—I didn’t. Plus, many people for a variety of reasons may find navigating a keyboard difficult. Where using the Shift key may be a simple inconvenience for some, people who are not blessed with full functioning fingers and/or hands encounter an arduous task. Even capitalizing the word “I” (“i think i will go”) can present a challenge. The primary goal of AutoHotkey is to make your Windows life easier. Continue reading

AutoHotkey Tip of the Week: Understand How Hotstring Activating Text Works

Sometimes We Limit Our Scripts by Not Grasping How AutoHotkey Features Respond

In AutoHotkey, we use Hotstrings for automatic text expansion and replacement—as in the extensive list of common misspellings found in the AutoHotkey AutoCorrect.ahk script. After loading this series of Hotstrings, if you misspell one of these words, AutoHotkey instantly corrects it. I’ve included this as a standard part of my main AutoHotkey script and often watch the Hotstrings in action when they correct one of my typos or misspellings.

Beginning AutoHotkey Hotstrings 200pxWhenever a Hotstring fires, it resets and waits for the next one. Most commonly, this occurs when we type a space, period or other punctuation as a Hotstring recognizer. One might fall prey to the misconception that every such space or punctuation key press causes a Hotstring reset, but not so. Hotstring monitoring only resets when a Hotstring event occurs (or with a mouse click or cursor movement). That means we can include spaces and punctuation in the activating strings (or Hotstring definitions) which appear after the first double-colon.

Light Bulb!Most AutoHotkey users might understand this fact about Hotstring activators, but I write about it here for those of us who either never fully realized the importance of this aspect of Hotstrings or we just forgot. Knowing this fact allows for a number of additional types of Hotstrings rather than limiting ourselves to standard text expansion and replacement. A perusal of the AutoHotkey AutoCorrect script lets us peek into how we can take advantage of this aspect of Hotstrings. 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

Finding US Zip Codes (AutoHotkey RegEx Tips Part 1)

Powerful Regular Expressions (RegEx) Perform Minor Computing Miracles—This Part 1 Uses Extracting US Zip Codes from Street Addresses to Introduce Regular Expressions as Merely a Set of Confusing Wildcards

In my last blog, “Parsing and Pasting One-Line Street Addresses (AutoHotkey Multi-Paste Trick)“, I added one-line street addresses to my MultiPaste.ahk script. That short AutoHotkey app uses a few Regular Expressions (RegEx) to identify and isolate key information:

  1. Cover 200Five-digit US zipcodes.
  2. UK postal codes.
  3. Remove excess tab characters in the results.
  4. Identify date formats.

I used RegEx functions for these problems because the basic string functions just didn’t offer the power needed without convoluted coding. RegEx provides fairly simple solutions (although possibly confounding to the neophyte).

Continue reading

Formatting Fonts and Colors in AutoHotkey GUI Window Controls

Guidelines for Setting Text Styles in AutoHotkey GUI (Graphical User Interface) Controls—You Can Make Your GUI Windows Easier to Read by Changing the Text Font and/or Color of Individual Controls

While AutoHotkey doesn’t offer the same detail control of color, font, and text style that you get in graphics programs, you can enhance your GUI pop-up windows with well-placed style changes. But to get the most from your adjustments, you need to understand how AutoHotkey executes these modifications.
Continue reading

Timing Script Speed (AutoHotkey Quick Tip)

Certain Types of Subroutines Tend to Eat Up Time (Loops, On Screen Changes, Multiple Drive Accesses, etc.)—Use This Simple Timer Routine to Figure Out How to Increase AutoHotkey Script Speed

Anytime you use AutoHotkey to make iterative changes in the controls in a GUI (Graphical User Interface) pop-up window, force multiple access to hard drive files, or implement repetitious subroutines (almost always with some form of a loop), you run the risk of slowing down your scripts. Minor changes to your script can make a significant difference in how fast it runs. Continue reading

The Duality of Curly Brackets in Hotstrings (Beginning AutoHotkey Tips)

Curly Brackets {…} in Hotstrings Both Insert Special Features and Neuter Hotkey Modifying Characters—When Properly Used, They Add Flexibility to AutoHotkey Hotstrings

Sometimes you want to do more than simple text replacement with your AutoHotkey Hotstrings. The key to adding those special features lies with embedding either manual keys within curly brackets (i.e. {Left 5}) or adding Hotkey action directly (without curly brackets) such as CTRL+I (^i for italics) or CTRL+B (^b for bold). The fact that the curly brackets {…} behave in two different manners can cause confusion. Continue reading

Beginning Hotstring Tricks for Expanding Acronyms (AutoHotkey Tips)

Hotstring Techniques for Expanding Abbreviations Only When You Need Them, Plus How to Sound British…Sort Of

One benefit I’ve discovered when using my InstantHotstring.ahk script includes quickly checking the effects of the various Hotstring options. Without re-editing and reloading an AutoHotkey script, I can test the assorted options and see how they modify the behavior of each Hotstring. This helps me understand how to solve some Hotstring problems. Continue reading