Hotkey fires randomly when held down... + Performance question

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
GothicIII
Posts: 20
Joined: 17 May 2022, 04:16

Hotkey fires randomly when held down... + Performance question

Post by GothicIII » 05 Jun 2022, 10:36

Hello there,

maybe there is a simple solution to this. Assume a hotkey like this:

Code: Select all

a::b
If I press it one at a time, it works. But when I hold it, it makes a sequence like this:
bbbabbababbaabba

Is this expected behavior and I need to use smth like GetKeyState() to fix it?

Bonus question:
How hard is the performance penalty if I use HotIfWinNotExist() + Hotkey "",function ?

Background:
Wanted to modify US International layout for keys exclusive to my country since the original bindings are counter-intuitive.

CptRootBeard
Posts: 26
Joined: 16 Nov 2020, 14:47
Contact:

Re: Hotkey fires randomly when held down... + Performance question

Post by CptRootBeard » 01 Jul 2022, 10:11

Maybe your SendMode is set differently? The basic remap you're showing works just fine for me.
Here's an adjusted example you can try straight from the Remap pages of the docs (https://lexikos.github.io/v2/docs/misc/Remap.htm#remarks):

Code: Select all

*a::
{
    SetKeyDelay -1   ; If the destination key is a mouse button, SetMouseDelay is used instead.
    SendEvent "{Blind}{b DownR}"  ; DownR is like Down except that other Send functions in the script won't assume "b" should stay down during their Send.
}

*a up::
{
    SetKeyDelay -1  ; See note below for why press-duration is not specified with either of these SetKeyDelays.
    SendEvent "{Blind}{b Up}"
}

As for the performance hits with #HotIf, you'll have to try it out on your machine and see what happens.
I can't imagine it would be all that severe, but then again, the remap you posted also shouldn't be causing you any issues.

GothicIII
Posts: 20
Joined: 17 May 2022, 04:16

Re: Hotkey fires randomly when held down... + Performance question

Post by GothicIII » 04 Jan 2023, 16:01

I forgot to answer this :(

This was no AHK problem. It was a Windows problem. My a::b example was too simple. I wrote the german Umlauts (e.g. ä) with Ralt+a.
The problem manifested because despite having a US-Layout keyboard windows was still detecting RALT as ALT-GR and it did this sporadically when holding the key. So ahk did everything right.
I realized that when I logged the key stroke events.

To remedy this I had to explicit add the US international Keyboard to the german language pack and delete the german keyboard layout instead of adding English as language.

Post Reply

Return to “Ask for Help (v2)”