I want to launch my function mToggler() only when holding Win keys (left or right) for more than 800 ms.
But on the other hand I want not to lose bringing Start Menu with this hotkey short tap nor other Win+<key> shortcuts (like Win+D for Show Desktop).
Because I working on an "module" script code this will be #included in other main AHK script file, so I define hotkey by Hotkey command, not :: hotkey definition:
Code: Select all
Hotkey, LWin, mToggler
I tried many solutions but none working fine.
My last try was something like this, but there are some glitches:
- not work with shortcuts like Win+D
- multiple hold-hotkey fires, when hotkey is hold much longer than initial threshold time (e.g few seconds)
Code: Select all
mToggler()
{
KeyWait, %A_ThisHotkey%, U T0.8
If (!ErrorLevel) { ; short tap
SoundBeep 2000, 50
Send {%A_ThisHotkey% Down}
Send {%A_ThisHotkey% Up}
} else { ; hold detected
SoundBeep 200, 200
; ... rest of the function code ...
}
}
Hotkey, LWin, mToggler
And how modify it to fix above two glitches?