Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v1) • Re: Hotstring to trigger actions by long press last letter.

$
0
0

Hallo,
try:

CODE:

:*:vare::
Time := HoldLastCharacter()
Switch { ; the first case that evaluates to True is executed
Case Time >= 2200:msgbox, action 3 triggered
Case Time >= 1200:msgbox, action 2 triggered
Case Time >= 200:msgbox, action 1 triggered
} Return

HoldLastCharacter() {
Time := A_TickCount
BlockInput, On
KeyWait,% SubStr(A_ThisHotkey, 0)
BlockInput, Off
Return, A_TickCount - Time
}



Thanks for trying to help! Your code is great and concise, but it didn't cover the 3rd case.

If I just type out vare normally without holding down "e" key for more than 200ms, then it should just type out vare normally without triggering anything or delete text. Your code will delete the hostring text, "vare" even if I short press "e" key. I have tried to get the text for the hotstring with StrReplace, and then using sendinput after the hotstring has been deleted due to trigger, but if I type too fast, it still interferes my typing flow. Basically the 3rd case is to prevent accidental trigger and interfering with normal typing flow. Not sure if that makes sense.

Statistics: Posted by haomingchen1998 — 30 minutes ago



Viewing all articles
Browse latest Browse all 579

Trending Articles