AutoHotkey Tip of the Week: Channeling Text to a Tagged Window

When Collecting Information from Various Sources, Send the Text Directly to an Unseen Text Editing Field

Last time in “Tricks for Tracking and Activating Target Process Windows“, I demonstrated a technique for tagging and tracking a window using its Unique ID. After tagging any window with one Hotkey combination, you can instantly recall it with another. While a pretty cool trick, the question of when would you ever use it arises. This time I offer a practical tool for gathering information from various digital sources (Web pages, documents, e-books, etc.) into one text editor window—without jumping back-and-forth while doing cut-and-paste operations. Continue reading

AutoHotkey Tip of the Week: The Eval() Function for Hotkey Math Calculations and Text Manipulation

The Classic Eval() Function Solves Problems You Didn’t Even Know You Had by Calculating and Resolving AutoHotkey Functions and Expressions Found in Text Strings!

When I work on particular AutoHotkey solutions, often I find myself in the middle of a treasure hunt—picking up hidden gems along the way. Although operative for years, I didn’t know these valuable tools existed until I went searching for answers to a seemingly unrelated problem.

EvalfunctionMsgBox2For example, the simple question about capitalizing sentences led me to the RegExHotstrings() function discussed last time. As I dug deeper into the math-side of dynamic Hotstrings, I discovered the Eval() function. While many old AutoHotkey hands have employed the Eval() function for years, I didn’t understand its power until I used it in the investigation. (Even now the Eval() function does way more than I comprehend. I’ve only scratched the surface of its capabilities.) 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 Tips of the Week: The ComObjCreate() Function for Web Page Downloads, E-Mail, and Text Audio

While AutoHotkey Directly Supports Most Windows Features, the Flexibility of the ComObjCreate() Function Adds More Useful Capabilities—Especially for Capturing Web Data, Sending E-mail, and Reading Text Out-Loud

A number of my scripts use the ComObjCreate() function in various forms. Most of them I copied from the AutoHotkey Forums and modified for my own purposes. In this blog, I highlight the ComObjCreate() applications I use most, then offer a list of other forms of the function you may find useful.

How I Use ComObjCreate()

Synonym Page
The SynonymLookup.ahk script pulls replacement terms for the highlighted word “Page” from the Web.

While AutoHotkey supports many of these features in one form or another, directly accessing the COM (Component Object Model) might provide a solution you can get by no other method. I use the ComObjCreate() function in three ways:

  1. Collect data from Web pages (ComObjCreate(“WinHttp.WinHttpRequest.5.1”)).
  2. Send e-mail directly from an AutoHotkey script (ComObjCreate(“CDO.Message”))—no mail program required.
  3. Use the computer voice to read text (ComObjCreate(“SAPI.SpVoice”)).

While I haven’t found much additional information about the ComObjCreate() function posted on the new AutoHotkey forum, the old forum contains a useful COM Object reference list. You don’t need to know how they work—just how to use them. Continue reading

AutoHotkey Tip of The Week: Evaluating Deprecated AutoHotkey Commands

As Time Passes, You May Notice More and More Deprecated AutoHotkey Commands in the Online Documentation—When Should You Rewrite Your Scripts and When Should You Ignore the Changes?

While working on the latest version of the QuickLinks.ahk script, I saw that the syntax for the Loop (files & folders) command for the reading the names of directories and files had changed in the online AutoHotkey documentation. (It’s about time that I noticed since it changed back in 2015.) In the original program I used:

Loop, C:\Users\%A_UserName%\QuickLinks\*.*, 2 , 0

and

Loop, %A_LoopFileFullPath%\*.*, 1 , 0

The powers-that-be deprecated that form of the command substituting:

Loop, Files, C:\Users\%A_UserName%\QuickLinks\*.*, D

and

Loop, Files, %A_LoopFileFullPath%\*.*, FD

While the new syntax seems a little clearer, it appears to act in the same manner as the original (still operational) form of the command. A person may ask, “Why the change the command at all?” Continue reading

AutoHotkey Tip of the Week: Adding Icons to Menus the Easy Way(?)

Inserting Icons into Your AutoHotkey Menus Makes Options Standout and Easy to Navigate, But You May Need to Prioritize the Methods for Adding Icons

I’ve employed icons in my QuickLink.ahk script for many years, but the process I used for adding them to menu items always felt awkward and messy—too much special-purpose code.

I want the script to standalone without needing much tailoring. Most changes should occur in Windows File Explorer by creating folders or editing shortcuts. Then the QuickLinks.ahk script should read all the Menu items from that folder/file structure—including menu icons. However, my implementation of icons gets a bit sloppy. For my own QuickLinks, I added numerous special lines of code to deal with the inconsistencies in how Windows deals with folder and file icons. I’ve never felt comfortable with how it worked.

My recent work implementing the Switch/Case statements has prompted me to return to my original goal of producing a script needing little or no adapting. That means not only constructing the AutoHotkey menu directly from the folder/file structure shown in Windows File Explorer, but the menu icons themselves should load from those folders and shortcut files without requiring additional unique lines of AutoHotkey code in the script.

Continue reading

AutoHotkey Tip of the Week: Save Time with CodeQuickTester for Testing and Modifying Scripts

Stop Creating Temporary Files to Check Out the New Scripts You Find on the Web—CodeQuickTester Directly Runs AutoHotkey Code without Saving

Since I consider educating motivated users about how to write and implement AutoHotkey scripts my primary purpose in life, I rarely recommend specific “user-friendly” AutoHotkey tools. Although they make scripting simpler, easy-to-use programming apps often interfere with a person’s understanding of the inner workings and hidden mechanism of AutoHotkey.

Don’t misunderstand me. I’m not against anyone using any tools that make life easier but my job is to teach how to get it done—not deliver canned, finished products. That’s why I rarely review other AutoHotkey scripts. However, every once in a while, I find an AutoHotkey app (such as Ryan’s RegExTester) which enhances understanding while making the coding process a little easier. CodeQuickTester by GeekDude falls into this category. Continue reading

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

Parsing and Pasting One-Line Street Addresses (AutoHotkey Multi-Paste Trick)

Another Pet Peeve…the Windows Copy-and-Paste Doesn’t Make It Easy to Insert Street Addresses and Postal Codes into Forms

I’ve noticed that many applications and Web pages list street addresses on just one line:

Jack Dunning, 1234 Main Street, Any Town, MI  90571

This makes sense and saves space when compared to a three or four-line address listing:

Jack Dunning
1234 Main Street
Any Town, MI  90571

However, when using the Windows Clipboard for a copy-and-paste operation, a person still needs to jump between the two windows a number of times—unless he or she uses a parse-and-paste tool such as MultiPaste.ahk. Continue reading