AutoHotkey News 2025-04-03 – Pay $20, walk away with $100! It must be a SCAM Right❓

AutoHotkey Newsletter

Howdy %Name%,

Imagine you get the following message from your bank:

Hello %name%,

Since you are a great client we are offering an exclusive sale to you.

For the next 5 days you can drop by and purchase $100 dollar bills for $20 each.

There are no limits and no strings attached.

My question to you %name% is:  How many $20s would you bring to your bank❓

Would you borrow from your friends & family❓

After all, it seems like a crazy deal right?

You can spend some money now and directly get back 5X?

What if that multiplier was higher❓

Would if it was 20X or 50X?

As crazy as this sounds, that is exactly what you’re doing when you learn AutoHotkey

By learning to automate your work, you are automating what used to take you, your team, your employees time!

And, when done right, you’re not only saving time your reducing the likelihood of human error!

If you want to speed-up the process of buying money, get on my calendar and we’ll figure out how we can help you!

Now on with the show…

Learn how to Master VSCode Make the switch to v2 Intro to AutoHotkey Intermediate AutoHotkey Intermediate ObjectsGUIs are Easy w/AutoHotkey Access all our Courses; Quit when you want

manually


Watch out for this Gotcha❗

A while back we were getting a list of files in a folder and ran into a weird “bug” (or so we thought.)

During an AHK Hero group Isaias explains what went wrong and what to look out for.

I excerpted the discussion which you can see here.

Building a List of Files and-or Folders in AutoHotkey v2
Building a List of Files and-or Folders in AutoHotkey v2


Easily Merging Audio or Video Files

If you have a bunch of Audio or Videio files you want concatenated together, our Media Merger is a great tool for you!

It, very quickly, merges together the media files faster than grandma hits ‘Reply All‘ on a church email chain.

Take a look at it in this video

Easily Merge Audio or Video files with Media Merger
Easily Merge Audio or Video files with Media Merger


Are you Sharing your Screen with AI❓

In this video I have Google’s Gemini model explain how Effortless Video Reducer works..

What’s really amazing is that Gemini didn’t “know” my program.  It had never seen it before and i didn’t share the source code.

This means it’s pretty darn smart!

If you’re stuck, you can share your screen and ask it for help!

Use AI to help Document your AHK Scriptsv
Use AI to help Document your AHK Scriptsv


Improving People’s Lives: Story #91

We updated our AI translator to automatically send the translation to Zoom Chat.

It’s not perfect, but it is much better and easier to use!


What we’re reading


AI / Chat GPT-3 News / Usage


⚡️Productivity tips:

In Windows Explorer you can toggle the preview view using Alt+P


A spot of Humor:  This is very accurate!

Developer VS Tester
Developer VS Tester | Developers Memes | Testers Memes | Developers fun | Tester Fun | War | Funny


What we utomated this week with AutoHotkey #91

In this week’s episode of what we automated with AutoHotkey I walk through

What we Automated with AutoHotkey #91
What we Automated with AutoHotkey #91


Client’s say…

This is a game changer and we are very Blessed to have Joe and his team working in helping us in utilizing the wonderful opportunities to grow with new technologies available  to us.

Again, thank you for all the support you give us.   — Stephanie Holland


Cartoon superhero mascot in green costume beside the bold text AHK Hero on a yellow background AHK Hero

Consider joining the AHK Hero club! Members receive 25% off courses, consultations, tutoring, done for you project work, etc.    Currently we have over 429 hours of recordings teaching AutoHotkey that is exclusive to AHK Hero members❗

During this Friday’s call we’re planning to discuss:

They also have access to exclusive & pre-released content and a 3 hours a week where we help people with their AHK issues (the Saturday calls are geared towards people new to AutoHotkey.)


️ Quotable quotes

  • Whatever Your Mind Can Conceive and Believe; We can create it for you! — Joe Glines
  • Implement More and Innovate Less❗ — Joe Glines
  • The more random you are, the less success you’ll have — Dan Kennedy

AHK Newsletter⏩SHARE WITH A FRIEND⏩

Do you know someone that would benefit from learning useful automation tips like the gems in today’s issue?  Take a second and forward this newsletter and bask in the glow of their undying gratitude.  Was this email forwarded to you?

Sign up for this Newsletter here.  We never share your email with anyone.  Ever!


The-Automator

Joe, Isaias, Irfan, Denilson and staff


P.S. When you automate your process you’re investing in the future!

If you would like help automating your work, check out my calendar and schedule a call today!

Getting Last Active Window and Race Conditions

Briefing: Solving “Last Active Window” Failures in AutoHotkey

1. The Core Problem: Unreliable “A” (Active Window) Identification

The central issue discussed is the occasional and seemingly random failure of AutoHotkey’s “A” variable, which is intended to refer to the currently active window. While users naturally assume there’s always an active window, the underlying Windows API (GetForegroundWindow) can return NULL “in certain circumstances, such as when a window is losing activation.” This leads to “Target not found” errors in AutoHotkey scripts that use “A”.

  • Random Failures: Iseahound highlights this unpredictability: “There’s a non-zero chance that any code that uses ‘A’ will bring up a Target not found error. It’s not clear to me why it fails, seemingly randomly, but should there be a best practice or some codebase change to mitigate this error?”
  • User Expectation vs. Reality: “As far as the regular user is concerned, there is always an active window.” This disparity between user expectation and the system’s occasional lack of a foreground window is a key frustration.
  • Race Conditions: Lexikos points out the inherent challenge: “Everything you do with window, keyboard or mouse automation is prone to race conditions and conflicts, since forces outside the script, like the user himself, can affect the state of the window. ‘A’ is no different to any other window specification in that respect.” This means the window considered active at one moment might not be in the next, or could be in a transitional state.

2. Causes of “A” Failures

  • Window Transition States: The primary cause is identified as the brief periods during window activation changes when GetForegroundWindow returns NULL. Andybody notes, “I sometimes have an issue when the taskbar receives focus as the active window (briefly). This seems to happen when window focus changes sometimes (like during minimize).”
  • Hidden Windows: Lexikos clarifies a specific scenario: “‘A’ intentionally does not match the foreground window if it is hidden and DetectHiddenWindows is off. Before assuming that ‘A’ is unreliable, be absolutely sure you have DetectHiddenWindows on.” An example given is another AutoHotkey script’s hidden main window being active.
  • Misconception of “Active”: Lexikos corrects a common misunderstanding: “‘A’ means ‘the active window’, not ‘the window the user is looking at’. Your perception doesn’t determine fact.” This means what a user sees as active might not always align with the system’s GetForegroundWindow state.
  • Race Condition Between Checks and Actions: Kczx3 raises a valid concern: “Wouldn’t there also be a non-zero chance that the active window when WinExist was called is now losing activation when PostMessage is called?” Descolada acknowledges this, stating, “that is true, which is why my example isn’t using ‘A’ as WinTitle but instead Last Found Window, which should mean that it is guaranteed that the message is sent to an actual window.” However, Lexikos counters: “How can it guarantee that, when the last found window might have been destroyed?”

3. Proposed Solutions and Best Practices

The discussion revolves around various approaches to handling these “Target not found” errors.

3.1. Error Handling Mechanisms

  • try {} catch TargetError {return}: Iseahound initially resists this as a systematic solution, arguing it shouldn’t be required for a “bs TargetError” when “A” is expected to always work. However, later, and as the topic’s “solution,” iseahound concludes: “I’m willing to close this topic because it’s pretty clear that there’s only one real solution: wrapping the entire function in a try block.”
  • Arguments for try-catch: Lexikos strongly advocates for try-catch, stating that for unexpected failures, “the only sensible fallback would be to do nothing. That is easily achieved with three letters (and a space): try.”
  • Nested try-catch Issue: Iseahound presents a logical argument against wrapping every single WinXXX or ProcessXXX function in its own try-catch block: “If every WinXXX function needs a try catch block, and if a WinXXX function is placed inside the catch block, then by weak induction there is an infinite set of nested try-catch blocks.”
  • OnError Function: RaptorX proposes using the OnError function more broadly. This allows for centralized error handling, logging, and user notification without cluttering every function with try-catch blocks. “Now I dont have to enlcose all my Win and Process functions in try statements -> my log function handles what to do or what to tell the user.”
  • Specific Error Types: Iseahound suggests throwing “a specific target error, and maybe a directive to silence those errors.” This would differentiate between a legitimate target error (e.g., specific ahk_id not found) and an “A” failure.

3.2. Robust Window Identification

  • Checking WinExist(“A”): Descolada suggests explicitly checking for the existence of an active window: if WinExist(“A”). However, kczx3 points out the race condition between the check and the action.
  • Using Last Found Window (WinGetTitle(hwnd)): Descolada attempts to use the “Last Found Window” after WinExist(“A”) to ensure the message is sent to an actual window. However, Lexikos questions this guarantee if the window is destroyed.
  • Waiting for an Active Window (WinWait(“A”)): Eugenesv suggests making “A” wait for the next active window with a timeout. Lexikos and others agree that WinWait(“A”,, timeout) is a more robust approach than WinExist(“A”) followed by an action, as it inherently waits for a window to become active. RaptorX demonstrates this by assigning active_window := WinWait(‘a’) in a try block within a while loop, allowing it to retry until an active window is found. Lexikos explicitly states: “active_window := WinWait(‘A’,, 5000) if !active_window throw TargetError(“Could not find active window”)”

3.3. Philosophical Approaches to Error Handling

  • Exceptions for Debugging vs. Runtime: Iseahound initially states, “The code cannot ever throw exceptions, it can only exit early. Exceptions are for debugging purposes only.” RaptorX disagrees, arguing that “Errors signal that something wrong happened outside of your expectations.” RaptorX advocates for a mixed approach of return values for expected outcomes and exceptions for unexpected, unhandled situations.
  • “Do Nothing” Fallback: Lexikos argues that for “A” failures, the most sensible fallback is often to “do nothing” rather than operating on a potentially unintended window (like the taskbar, which could lead to undesired system actions like the shutdown dialog).
  • Recursive Recovery Schema: Iseahound, in their concluding post, revises their opinion on try-catch, suggesting a “recursive recovery schema starting from WinGetList.” This implies a more complex error handling strategy that attempts to return the process to a valid state, potentially by closing windows with invalid states.

4. Key Takeaways and Recommendations

  • “A” is Not Always Reliable Instantly: Users must acknowledge that “A” relies on GetForegroundWindow, which can return NULL during rapid window transitions. It’s not a constant, always-present value.
  • Race Conditions are Inherent: Interactions with external applications (windows, mouse, keyboard) are subject to race conditions. Code should anticipate and handle these.
  • Robust Active Window Identification:Use WinWait(“A”,, Timeout): This is the most recommended approach for obtaining a handle to the active window reliably, as it waits for a window to become active within a specified timeframe.
  • Explicitly Check for Existence: While WinExist(“A”) alone has race condition risks if followed immediately by an action, it can be part of a robust strategy when combined with WinWait or in specific conditional checks.
  • Strategic Error Handling:Centralized OnError: For general application robustness and user experience, using a global OnError function for logging and graceful handling of unexpected errors is highly recommended.
  • Targeted try-catch: While not every line needs a try-catch, critical operations involving window interactions, especially those using “A,” should be wrapped in try-catch blocks to prevent script crashes and allow for specific recovery logic or graceful exits.
  • Avoid Blind Operation: Do not design automatic countermeasures that could operate on an unintended window. If “A” fails, “do nothing” is often the safest default.
  • Differentiate Error Meanings: Understand the difference between a TargetError for a specific, known window (e.g., ahk_id) and one for “A.”
  • DetectHiddenWindows: Ensure DetectHiddenWindows is enabled if your script needs to interact with hidden windows that might become active.

In summary, while the user expects “A” to always represent a valid window, the reality of Windows’ foreground window management means it can occasionally fail. Developers should implement robust error handling, preferring to wait for a stable active window state or gracefully exit/log errors rather than risking unintended actions.

AutoHotkey News 2025-05-29: Congratulations Jon❗

AutoHotkey Newsletter

Howdy,

Last Saturday my 18 year old son, Jon, Graduated Highschool❗

It was bitter sweet for me.  I’m super proud of him however, seeing AI’s growth, I’m not convinced that a college degree is going to be “worth” what it was in the past.  (Keep in mind I have 4 degrees)

I’m hoping to have Jon work with my over the summer and help him learn some great computer skills which will help him for the rest of his life.

Graduate in red cap and gown holding a diploma with three adults beside him on a football field at night

One super-smart thing I did when he was young was found a game that made learning to touch-type “fun”.   I think he was around 9 years old when he beat my wife at a typing test!

I taught him some basics of AutoHotkey in the past but, at first, I’ll be having him go through our “Rise above PC Incompetence” course so he’ll be light-years ahead of kids his age (and many adults for that matter.)

Congrats Jon!  I love you and am super proud of you!

Now on with the show…

Learn how to Master VSCode Make the switch to v2 Intro to AutoHotkey Intermediate AutoHotkey Intermediate ObjectsGUIs are Easy w/AutoHotkey Access all our Courses; Quit when you want

3hourfix


Our most Used Libraries

A few weeks ago I got to wondering what were our most-used AutoHotkey libraries.   Well, in this video, I walk through how I figured that out and showed which ones were the ones we use a lot!

Which AHK Libraries, Objects, Functiosn we #include Most in our Scripts

Which AHK Libraries, Objects, Functiosn we #include Most in our Scripts


One critical difference between SetTimers and Loops

We were working on a project with our new employee, Denilson, out of Brazil when Isaias realized there was a great teaching lesson!    So of course I hit record and captured a simple but very important difference between SetTimers and Loops

Learn the surpising differnce between Loops and SetTimers | AHK Hero Extract
Learn the surpising differnce between Loops and SetTimers | AHK Hero Extract

BTW If you’re not familiar with SetTimers or Loops we cover both in our amazing Intermediate AHK v2 course!   Don’t’ forget, our courses come with a 200% money-back guarantee!

200% Money Back Guarantee badge with a yellow and green starburst seal for AHK courses


Advanced Hotkey Tips & Tricks

A few months back, during an AHK Hero call, we walked through some really great Hotkey tips and tricks.  Even if you think you’re familiar with Hotkeys, I highly suggest you check out this video!

Advanced Key Combination Hotkeys – AHK Hero Extract
 Advanced Key Combination Hotkeys - AHK Hero Extract


Are you Tired of AutoHotkey GUIs❓

GeekDude often attends our AHK hero calls.   During one call a while back he provided some great examples of how to generate Gorgeous GUIs with the WebViewToo class.   I extracted part of the call and you can check it out here.

Learn how to create Beautiful HTML GUIS with this amazing AHK V2 library WebViewToo
Learn how to create Beautiful HTML GUIS with this amazing AHK V2 library WebViewToo


Improving People’s Lives: Story #51

We recently created a super-simple tool that uses FFMPEG to record your desktop and mic.  This will allow our client to “hit a button” start talking and pointing on her screen about changes she’d like to see” and hit the “stop” button.

So much easier than trying to write-up a description of what you’re wanting done!


What we’re reading


AI / Chat GPT-3 News / Usage

Google Veo 3 Changes Everything – Video, SFX, and Speech all at Once
Google Veo 3 Changes Everything – Video, SFX, and Speech all at Once


⚡️Productivity tips:

In MS Excel you can use Alt + = to trigger AutoSum


A spot of Humor:  Come on, I’m sure one of you owns one of these


Client’s say…

“There’s no way I could have accomplished what we’ve done without your support!” — Stephanie Holland


Cartoon superhero mascot in green costume beside the bold text AHK Hero on a yellow background AHK Hero

Consider joining the AHK Hero club! Members receive 25% off courses, consultations, tutoring, done for you project work, etc.    Currently we have over 420 hours of recordings teaching AutoHotkey that is exclusive to AHK Hero members❗

You can watch 1 hour a day for a year and not repeat content! That’s a lot of AHK Learning!

During this Friday’s call we’re planning to discuss:

They also have access to exclusive & pre-released content and a 3 hours a week where we help people with their AHK issues (the Saturday calls are geared towards people new to AutoHotkey.)


️ Quotable quotes

  • Great achievement is usually born of great sacrifice and is never the result of selfishness — Napoleon Hill
  • Learn how to calculate the future cost of your bad decisions — Joe Glines
  • It’s easy to see stupid in other people — Dan Kennedy

AHK Newsletter⏩SHARE WITH A FRIEND⏩

Do you know someone that would benefit from learning useful automation tips like the gems in today’s issue?  Take a second and forward this newsletter and bask in the glow of their undying gratitude.  Was this email forwarded to you?

Sign up for this Newsletter here.  We never share your email with anyone.  Ever!


The-Automator

Joe, Isaias, Irfan, Denilson and staff


P.S. Time goes by faster than you can ever imagine!

It seems like only yesterday Jon was a toddler.  As Darius Rucker sang in this wonderful song It won’t be like this for long

Darius Rucker – It Won’t Be Like This For Long (Official Video)
Darius Rucker - It Won't Be Like This For Long (Official Video)