AutoHotkey Tip of the Week: Quick Menu for Activating Open Windows

With a Few Modifications, the WindowList.ahk Script Pops Up a Menu of Open Windows for Quick Activation—Plus, How to Detect When a Windows Opens or Closes

I originally used the WindowList.ahk script as a demonstration of how to use the GUI DropDownList control as a list of selection options for activating open windows (included in the Digging Deeper Into AutoHotkey book). Once, while testing someone’s script, it proved very useful. I could not find the GUI window generated by the code. The script had placed the target window somewhere off the screen. The scriptwriter originally used a second monitor—which I didn’t have. The WindowList.ahk script moved the window back into my view.

As I reviewed the script, I realized that building a pop-up menu of open windows could serve a purpose similar to the QuickLinks.ahk script—except, rather than launching apps and Web sites, the menu would activate open windows. Now, that’s something that I can use!

I often keep numerous windows open simultaneously. Generally, I locate a window by hovering over the Windows Taskbar then selecting the image which looks right. It takes a second for the thumbnails to appear, then hovering over each helps me make my selection. But what if I could maintain a menu of all open Windows available in a menu for instant activation? 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: Increase the Flexibility of Menus by Passing Data with the BoundFunc Object

Streamline and Add Power to Hotstring Menus by Binding Action Parameters Directly to Each Menu Item

*          *          *

If you use AutoHotkey menus, then you may find this blog the most useful menu tip yet. At first, using the BoundFunc Object to pass data may seem confusing, but, once understood, it opens up many more opportunities for taking advantage of menus in your AutoHotkey scripts.

*          *          *

HotstringSubMenus

As often happens when working on an AutoHotkey script, a deeper understanding of the available tools completely changes the direction of the project. While all of the Menu tricks I’ve offered in the past HotstringMenu.ahk scripts still work (and you may want to continue using many of those techniques), the following approach which combines arrays, the variadic function parameter, and the boundfunc object creates a cleaner, more functional structure for generating Hotstring replacement menus. In short, implementing the boundfunc object allows me to drop many of those previous menu tricks and build menus using virtually any menu item format without regard for their later use through the value of the A_ThisMenuItem variable.

Continue reading

AutoHotkey Tip of the Week: Fold Long AutoHotkey Menus into Columns

Sometimes We Resort to Programming Trickery to Make Autohotkey Menus Look Better

The Windows Menu control is part of the Windows operating system. AutoHotkey offers you the Menu command for setting up and altering custom menus using this built-in control. However, much of the inflexibility of AutoHotkey menus results from the limitations of the Windows Menu object itself. This rigidity often forces us to resort to programming sleight-of-hand to accomplish many goals. Continue reading

AutoHotkey Tip of the Week: Flexible AutoHotkey Hotstring Menus Using Arrays

New Parameters for the HotstringMenu() Function Adds Flexibility and Power to Pop-up Menus

In my last blog, I started looking at adding the variadic parameter (accepts multiple inputs) and a Menu subroutine parameter to the HotstringMenu() function. While in the process of creating alternative Label subroutines, I found that changing a subroutine often called for a new menu-creating function. Rather than resorting to multiple functions, I decided to add one more parameter for tailoring the master function.

CoverImage200
A Multitude of AutoHotkey Tips and Tricks

Note: This blog discusses the use of AutoHotkey object-based arrays (simple and associative) with the function’s variadic parameter. A review of my books demonstrated that most included discussions of arrays (pseudo-arrays and object-based arrays). In particular,  Chapter 12.1.5 “Using Associative Arrays to Solve the Instant Hotkey Data Recall Problem” in the book Jack’s Motley Assortment of AutoHotkey Tips explains the difference between the various array types while offering a practical example of an associative array.

Continue reading

AutoHotkey Tip of the Week: Add Power to Any Command with Forced Expressions (%)—October 7, 2019

Use the Forced Expression Operator (%) to Adapt AutoHotkey Commands On-the-Fly

Light Bulb!Most AutoHotkey Version 1.1 commands use plain text as parameters. That means AutoHotkey interprets the text exactly as written—no quotes needed and no variables accepted. In version 1.1, this would limit the commands except for the availability of the traditional (or legacy) double-quote text replacement operator (%var%).

The %var% technique allows us to substitute any variable directly into an AutoHotkey command. However, using the forced expression operator (%) adds even greater flexibility and power to almost any AutoHotkey code. In many cases, rather than developing complicated subroutines, you can use this technique to embed expressions and functions directly into version 1.1 AutoHotkey commands. 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: 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

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

Pasting Date Parts into Forms (AutoHotkey RegEx Tips Part 4)

In Most Data Fields, You’ll Find It Simple to Paste Text or Numbers, But Inserting a Parsed Date Often Requires Extra Steps—Plus How to Change Date Paste Action Based on the Active Window Title

In the first three blogs of this RegEx series, I used Regular Expressions (RegEx) to identify and parse data prior to any paste operations. In this blog, I use a RegEx to identify and parse dates during the multi-part date paste operation. I use the previously introduced \d wild card (any numeric digit zero through nine) and the optional match modifier (the question mark ?), plus, I introduced how to create a selection list of possible matches by using a range of options (in this case, a forward slash, a dash, or a dot [/\-.] as date separators).

*          *          *

Cover 200When working with forms, dates often use three separate data entry fields—one for the month, one for the day, and one for the year. (In the UK, they swap it around to day/month/year.) In some forms, you need to enter a forward slash (/) to jump to the next entry item. Sometimes the form automatically jumps to the next field after entering two digits. In many Web pages, you need to tab between each data entry area. Sometimes, sending the entire copied date as a single string works.

Since I wrote the MultiPaste.ahk script to respond to a particular personal finance program, I set it up to Send the date delimited with slashes. If you want to do something similar for a different software package or Web page, then you may need to tailor the script. This blog shows you how to do that. Continue reading