Block keys auto repeat input until release.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
M_L
Posts: 13
Joined: 21 Mar 2016, 06:54

Block keys auto repeat input until release.

23 Apr 2019, 00:30

I can't find a way to solve this issue: Releasing the modifier key before the alphanumerial key leads to its input, produced by auto repeat, to pass through. So whenever I release the keys in the wrong order I get false input.

This hotkey

Code: Select all

~RButton & w:: LongPressCommand("w", ^l, ^f)
calls this function

Code: Select all

LongPressCommand(pressKey, quickCmd, longCmd) {
    KeyWait, %pressKey%, T0.3
    If ErrorLevel {
        Send %longCmd%
    } else {
        Send %quickCmd%
    }
    Keywait, %pressKey%,
}
How can I deactivate/disable/block the input of pressKey until it is released?
What I have tried so far:
- BlockInput: works, but blocks all input and thus other keys pressed could get stuck.
- Hotkey command: works, but can't differ between keys that already have a hotkey and those that don't, thereby destroying existing hotkeys for that key.
Rohwedder
Posts: 7647
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Block keys auto repeat input until release.

23 Apr 2019, 04:36

Hallo,
perhaps:

Code: Select all

~RButton & w:: LongPressCommand("w", "l", "f")
~RButton Up::
Key2 =
StringSplit, Key, A_PriorHotkey, &, %A_Space%
IF (Key1 <> "~RButton") Or !GetKeyState(Key2,"P")
	Return
SendInput, {Esc} ;close RButton Menu
While, GetKeyState(Key2,"P")
	Input, Key, T.1
Return
LongPressCommand(pressKey, quickCmd, longCmd)
{
	KeyWait, %pressKey%, T0.3
	If ErrorLevel
		Send %longCmd%
	else
		Send %quickCmd%
	Keywait, %pressKey%
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, hedehede81, ThePeter and 243 guests