Last February, AutoHotkey Release 1.1.28.00 Included Important New Hotstring Capabilities
A few months back while working on my latest book, Jack’s Motley Assortment of AutoHotkey Tips, I encountered a new x option for Hotstrings. The x option enables the running of functions and commands rather than replacing text. This new feature surprised me since, in the past, a one-line Hotstring would only do text replacement.
I immediately recognized that this approach to one-line action Hotstrings could immediately shorten a long list of function Hotstrings. However, closer scrutiny of the new AutoHotkey release revealed further (and possibly more important) new Hotstring functionality. In addition to the x option, the February AutoHotkey release includes:
A new Hotstring() function which adds dynamic capabilities to Hotstrings.
A new method for creating function Hotstrings by defining the function immediately after the Hotstring(s).
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.
While 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 →
All GUI controls (e.g. Edit, Text, MonthCal, etc.) offer options you can call with the initial Gui, Add command. ListView (and its sister TreeView) include similar options plus special functions for directly manipulating the control. Last time, we used LV_Add() to load the data table rows into the ListView control. This time, we use the LV_GetCount() function (the number of ListView rows) to limit the total number of iterations in a loop, LV_Modify() to focus on each table row in sequential order, and LV_GetText() to retrieve and store data in the row. Continue reading →
Both Hotkey Modifiers and Special Characters Might Disappear When Used in Regular Text. Usually, You’ll Find the Raw Mode the Easiest Solution for Vanishing Characters. Plus, a Secret AutoHotkey Hotstring Trick!
* * *
When I started working on this blog I thought I would hammer out a simple explanation of when to use the Raw option in AutoHotkey…and to a large degree I do that. However, in the course of testing both the Raw option and the backtick Escape Character, I discovered a secret undocumented feature of Hotstrings. In some special cases, it may come in handy for changing Hotstrings on-the-fly.
Refinement and simplicity are implied, rather than fussiness, or ostentation. An elegant solution, often referred to in relation to problems in disciplines such as mathematics, engineering, and programming, is one in which the maximum desired effect is achieved with the smallest or simplest effort.
In the last few blogs, I figured out a number of solutions for returning the insertion text via Hotkey combinations for multiple GUIs in the InstantHotkey.ahk script. Many of these approaches worked, yet I continued searching for a more elegant answer. Now, I present my best solution (so far) which includes the use of an AutoHotkey associative array. Continue reading →
Sometimes You’ll Find a Loop a Simpler Way to Match Things
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 →
When You Find No Obvious Way to Link Specific Data to an Object or Another Value, You Might Try Saving It to a Variable within a Variable
Sometimes you encounter a scripting situation where saving data to just any random variable doesn’t do the job. While creating variables and storing values is simple enough, you may find it difficult to recall those values at the right time. It’s important to know you’re getting the right data when you want it. Maybe using the value of a variable as a variable name (two-deep) will give you what you need. Continue reading →
Handy Window Transparency Wheel Using Macro Replacement Quickly Peeks Under a Window without Moving It, Plus the Difference Between % Var and %Var% Made Easy
The AutoHotkey online documentation goes into great detail about the traditional method for retrieving values from variables (%Var%) and the force expression evaluation method (% Var). It can take the new AutoHotkey user a little while to comprehend the differences between the two. In an effort to clarify the variations and help beginners to understand when to use which method, I offer an alternative way to view the operations. For the traditional method, I prefer using the terms macro substitution or variable name replacement. Once, you understand how it works, differentiating when and how to use each technique becomes easy.
The value-added trick comes when creating variables containing new variables on-the-fly by combining the two methods (i.e. forcing an expression % which contain a %Var% variable name replacement). The first step involves replacing the variable with its value, the new variable name (%Var%). The second step requires the forced evaluation of the new variable (% VarValue) as part of an expression.
* * *
A while back I installed a volume control operated by the mouse scroll wheel. Simply hover over the Windows Task Bar and scroll the mouse wheel up or down to adjust the PC speaker volume level higher or lower, respectively. A progress bar (shown at right) pops up displaying the changing volume level. I’ve added this convenient tool to my standard AutoHotkey script and use it all the time.
At a later date, while playing with window visibility, I set up a menu for changing the transparency level for the active window (shown at left). At the end of that blog, I suggested, “If you want to get really fancy, then you might use the mouse wheel to set the transparency (or opaqueness) level.” I’ve done just that with my new SeeThruWinWheel.ahk script. Now, by holding down the CTRL key while scrolling the mouse wheel, the window under the mouse cursor becomes less opaque (WheelDown) or more opaque (WheelUp). In the course of writing this short script, I implemented a number of AutoHotkey tricks worth discussing. Continue reading →
While Other Techniques Exist for Printing Directly from AutoHotkey, Make It Easy by Using Print Drivers from Other Programs
When I first considered printing from the cheeseburger recipe script, I didn’t realize how complicated printing from AutoHotkey can get. With any printing, a number of factors come into play. First, each printer model uses particular print drivers. Second, the format of the document affects the output and drivers. Third, you may need to choose from multiple printers. Continue reading →