AutoHotkey Speed Tips

A Collection of Techniques for Speeding Up Your AutoHotkey Scripts

I recently received the follow message from an AutoHotkey user perusing my blogs:

Jack, you can’t post false statements like this:

“However, the ternary does not provide better performance than the traditional If-Then-Else statement format.”

The ternary operator is inarguably faster than if/else and I encourage you to try this yourself.

I recently switched the core logic of my JSON parser from If/Else to ternary and saw an incredible speed increase. To the point where I only use If/If Else/Else statements when absolutely necessary (Ex: If I must have a loop in the middle of a check).

You can code entire blocks using nothing but ternary as long as you use proper parentheses, commas, and function calls.

There is a very well done AHK forum post that covers script optimizations and they report that ternary performs FORTY PERCENT FASTER than if/else statements.

Not sure if hyperlinks are allowed in these comments, so instead I’ll advise googling “AHK How to optimize the speed of a script as much as possible.” The first result should be the article in question. Pages 1 and 4 have tons of script speed gold in them.

I hope you’ll consider correcting/updating this article.

Groggy Otter

Comment on “AutoHotkey Toggles and the Ternary Operator”

I wrote that blog five years ago and I don’t know that I was talking about performance speed. I think I was referring to how the two expressions operate. In any case, I used a poor choice of words and have drawn a line through the comment.

Continue reading

Create Instant Windows Gadgets Using AutoHotkey Graphical User Pop-ups (GUIs)

One of the Easiest and Quickest Means for Building a Short, Useful PC App Takes Advantage of AutoHotkey GUI Controls—A Review for the Novice Scriptwriter

Many of my sample scripts available at the Free ComputorEdge AutoHotkey Scripts page use the built-in Graphical User Interface (GUI) tools available in the Windows operating system. Taking advantage of these Windows mechanisms demonstrate only one of the many reasons why the free AutoHotkey scripting language affords so much power. With a few lines of code, you can build Windows gizmos for an innumerable variety of applications. The GUI pop-up acts as the primary core for many AutoHotkey scripts. Easy-to-use and only requiring a minimum amount of programming, the GUI makes possible Windows gadgets for almost any use.

While almost all of my books discuss how to use GUIs in a number of different ways, the book AutoHotkey Applications: Ideas and Tips for Writing Practical AutoHotkey Scripts spends a great deal of time discussing various AutoHotkey Graphical User Interface (GUI) pop-ups with example scripts.

Continue reading

Use Alternative Filename Extensions for Special Format Files (Part Five: Finishing AutoHotkey GUI Scripts)

While Changing the Saved Filename Extension in the InstantHotstring.ahk Script Helps Protect Original AutoHotkey Files, the Technique Offers Additional Benefits…Plus, a No-Wait Progress Bar for Instant-Saves

Over the course of the past few blogs, I added protection to files containing AutoHotkey code by both including a one-line file header and changing the saved filename extension to .hsf. These steps have resolved my concern about overwriting any AutoHotkey scripts—from which I may have extracted Hotstrings and loaded them into the “under-construction” InstantHotstringMenuBar.ahk app. At times, I thought that adding the two techniques might be overkill but now I’ve come to realize that using an alternative extension provides benefits that may prove even more useful than my initial attempt at protecting .ahk files.

Continue reading

Use Progress Bars When Loading Large Data Files (InstantHotstrings Feature)

Long Load Times Make Us Wonder If Our Computer Has Crashed—Progress Bars Help Us Stay Patient

In the blog, Use the FileSelectFile Command to Save Instant Hotstrings to an AutoHotkey File, I discussed how the InstantHotstring.ahk script saves a set of newly created Hotstrings to a data file. The flip side of the coin reads those same (or any other) Hotstring data files into the InstantHotstring.ahk script, (Loading Hotstrings into the InstantHotstring.ahk Script from Any AutoHotkey (.ahk) File). The solution to reading Hotstring files introduced the problem of the long load times for large files (Timing Script Speed). Continue reading