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: Windows Trick for Adding Embedded Folder Icons to QuickLinks Menus

This Technique Accesses Icons Embedded in Windows Folders for Inserting into Pop-up Menus—Plus, the New Combined Switch/Case Statement QuickLinks QL_GetIcon() Function

I completely rewrote the functions from the last blog for adding icons to the menus in the QuickLinks.ahk script combining the two into a shorter prioritized list using Switch/Case statements. In the process—after investigating how to read icons embedded in Windows folder/directory listings—I discovered an interesting Windows secret. It turns out that this procedure requires a totally different Windows maneuver than that used for reading Windows Shortcut file icons.

The Windows Desktop.ini File

Ryan’s UnHideFiles.ahk script makes Windows Registry changes to hide and unhide files.

When you embed an icon into a Windows folder (right-click on the folder name in Windows File Explorer, select Properties and the Customize tap, then click Change Icon… and browse for icons), rather than saving the icon path and icon number in the folder itself—as Windows does for shortcut files—it creates a special hidden file named desktop.ini in that same folder. With Windows set to Show Hidden Files, folder and drives in the View tab of the Folder Options window, you can view the hidden desktop.ini file in that folder. (Tip: You can use Ryan’s UnHideFiles.ahk script to hide and unhide files and folders.) 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: 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

Total the Numbers Found in Any Document (AutoHotkey RegEx Tips Part 5)

For a Quick-and-Dirty Calculator, Use Regular Expressions (RegEx) to Pull Numbers from Documents or Web Pages and Total Them Up—Plus, a RegEx for Removing (or Extracting) Numeric IP Addresses

Shifting gears, I end the discussion of the MultiPaste.ahk script which parses copied data into component parts for easier paste operations into other documents. With this blog, I start working on another tool for simplifying a Windows task—addition.

Sometimes I see a list of numbers in either a document or a Web page which I would like to quickly total without loading a separate calculator. For example, the shopping cart program I use for my book sales offers a summary table of all recent sales. While I can use a reports section of the site to get more information (e.g. monthly sales), I want a tool to quickly highlight the desired entries and give me the total of the individual sales. To do that I use a Regular Expression (RegEx) specifically for extracting those sales numbers. 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

How to Send E-mail Directly from an AutoHotkey Script

Using Windows CDO COM, You Can Send E-mail Without Opening Your E-mail Program

RobotEmailCartoonIn my last blog, I wrote a short script for extracting data from a Web page without using a Web browser (“Quick and Dirty Web Data Extraction Script“). As a demonstration, I showed how to quickly download and cull a daily horoscope from an astrology site for display in a MsgBox window. It occurred to me that rather than using a Hotkey each time I wanted to view my horoscope, I would prefer to receive it each morning in an e-mail. That way I could set up the script to run automatically and push the data to me at the same time every day. Plus, I can view an e-mail on any device (e.g. smartphone, tablet, or non-Windows computer) without any special programming. This requires sending an e-mail via an AutoHotkey script. Continue reading

Wrapping Up the DateStampConvert.ahk Script (AutoHotkey Tips)

In Previous Blogs, I Used Regular Expressions to ID Dates Formats in Documents and Simulated Case/Switch Statements to Convert Month Names to Numbers. Now, I Build the Standard DateTime Stamp, Check for Valid Dates, and Deal with Two-digit Years, Plus Use the Function ByRef Method to Bypass Local Variables.

While in conversations with a reader who uses AutoHotkey to calculate the time span between two dates for figuring out new leases, I realized that a tool which captures formatted dates from any document and converts them into the DateTime Stamp format (yyyymmdd) would make using the HowLongYearsMonthsDays.ahk script even easier. That prompted me to write the DateStampConvert.ahk script. Continue reading

Adjust Windows Registry Settings with the AutoHotkey RegRead and RegWrite Commands

Sometimes a Simple Script Offers the Best Way to Learn More Advance Techniques in AutoHotkey

I’ve just posted a script written years ago by Robert Ryan (the person responsible for the very capable RegEx Tester) which displays hidden files by changing settings in your Windows Registry—a trick you can apply to many other Windows settings if you know where to find them.

UnHideFilesThe problem with setting folders or files to Hidden in their Properties window (right-click on selected folder or filename in Windows File Explorer and click Properties at the bottom of the menu) involves losing sight of them forever. Since the listing disappears from view, you can forget that it even exists. Windows offers a multi-step procedure for making all Hidden folders/files visible, but who can remember that? This simple UnHideFiles.ahk script saves the stress. Continue reading

Calculating Timespans in Years, Months, Days in AutoHotkey, Part 2 (Understanding the HowLong() Function)

Taking a Close Look at the HowLong() Function for Calculating Years, Months, and Days

In this blog, I discuss in its entirety the most recent AutoHotkey code for the HowLongYearsMonthsDays.ahk script (introduced in my last blog). I’ve broken it up into snippets in order to explain the purpose of each piece. To get a complete copy of the script check out HowLongYearsMonthsDays.ahk at the “ComputorEdge Free AutoHotkey Scripts” page or for a barebones version (without comments and inactive code) see “Function Calculating Timespan in Years, Months, and Days” at the AutoHotkey Forum. This blog reviews the nuts and bolts of calculating the timespan between two dates.

Continue reading