Hotkeys stop firing after a while

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Randy31416
Posts: 58
Joined: 15 Jan 2014, 19:09

Hotkeys stop firing after a while

Post by Randy31416 » 28 Jun 2022, 12:18

EDIT: This question has been simplified and made much more specific in a new post. See the new post instead. New post:viewtopic.php?f=76&t=106067

I have a very large AHK program, with lots and lots of hotkeys and lots and lots of #IFs, that has worked reliably under V1.1.33.02 for a long while. It breaks on every version since then in multiple ways. Recently I have begun a concentrated effort to get it working under the current version, V1.1.34.03.

One specific problem is that some of the hotkeys stop firing after a while. The debug window showing recent keystrokes seen by AHK may show the keys or it may not. For example, ^!+Numpad5 shows up as a sequence of downs and ups for all four keys. But !+G does not -- only the ALT and the SHIFT are seen.

In this second case there is a shortcut in the Windows All-User Start Menu that contains the Alt-Shift-G as its hotkey. When the AHK program begins, AHK nicely intercepts this !+G sequence and fires the AHK code defined for it. Under the old 1.1.33.02 version this behavior continues forever. Under 1.1.34.03, however, something happens after a while and then the Windows shortcut is what gets run: AHK loses its hotkey. The ^!+Numpad5 hotkey has no corresponding Windows start-menu shortcut, and in this case AHK simply does not fire its code. These are two specific examples: many keys stop working but others continue.

I've commented out any hotkeys that use & (so things line Capslock & G are not present in the code except as comments) because the changelog reveals several fixes involving these. Commenting out the #IFs, though, is another problem as the hotkeys are used in different ways in different programs. The !+G hotkey described above, though, is not under any #IF and it appears only once in the program. The ^!+Numpad5 appears once under an #IF and once, later, by itself.

I'd welcome ideas to try to isolate and fix the problem.
Last edited by Randy31416 on 04 Jul 2022, 07:49, edited 1 time in total.

User avatar
mikeyww
Posts: 26600
Joined: 09 Sep 2014, 18:38

Re: Hotkeys stop firing after a while

Post by mikeyww » 28 Jun 2022, 12:33

1. Remove all #If directives. Retest. If it works, then you solved the problem.
2. Shorten your script to be just one hotkey. If it works, add another one. Repeat until problem occurs. You then solved the problem.

Randy31416
Posts: 58
Joined: 15 Jan 2014, 19:09

Re: Hotkeys stop firing after a while

Post by Randy31416 » 28 Jun 2022, 16:54

The program has over 2400 hotkeys, roughly 80 #IFs, and 14500 non-comment lines, developed over more than a decade, and works perfectly with the old version. I'de been shortening it for a week or so and was down to 1100 or so hotkeys before asking here. And this is of course the obvious approach, hoping that something will reveal a change.

The problem for me is that this is the base script that supports everything I do on this computer: editors, explorers, emails, browsers, whatever. As I remove stuff from the script I can do less and less, easily, on the computer. I am hoping for some insight that might focus the effort.

Many of the changes to AHK between V1.1.33.03 and V1.1.34.03 have to do with failures of AHK to fire hotkeys under various conditions. I've eliminated the & operator and the InputLevel operations that are the cause of some of the failures mentioned in the changelog. Ultimately it is almost certain that the problem I am seeing is caused somewhere by a bug in my code -- true -- but it would be nice to find a smart search strategy for whittling the code down.

User avatar
mikeyww
Posts: 26600
Joined: 09 Sep 2014, 18:38

Re: Hotkeys stop firing after a while

Post by mikeyww » 28 Jun 2022, 17:32

You can chop half, test the rest, chop half, etc. That would probably cut your iterations to about a dozen.

If step #1 works, that's only one iteration. A lot of people go wrong with their #If directives.

Randy31416
Posts: 58
Joined: 15 Jan 2014, 19:09

Re: Hotkeys stop firing after a while

Post by Randy31416 » 04 Jul 2022, 07:51

This question has been simplified and made much more specific in a new post. See the new post instead. New post:viewtopic.php?f=76&t=106067

Post Reply

Return to “Ask for Help (v1)”