hi, I'm new with this so please help me with an easy to understand reply cuz i have 0 programming experience.
Need an script to these
1. i double tap "A" key to obtain a hotkey "+a" [shift+a if I'm right]
2. i hold "A" key to obtain a hotkey "+a"
3. i hold "+b" key to obtain a hotkey "a" key
Simple Double key tap and long press for same key
Re: Simple Double key tap and long press for same key
Welcome to this AutoHotkey forum!
An example is below.
An example is below.
Code: Select all
#Requires AutoHotkey v2.0
$a:: {
Static presses := 0, squelch := 300
hk := StrReplace(ThisHotkey, "$") ; Strip the dollar sign
If KeyWait(hk, 'T.5') ; If key was quickly released,
SetTimer(done, -squelch), presses++ ; then reset timer, and increment counter
Else Send('+' hk), presses := -1 ; If held, send the shifted key
done() { ; Key presses have ended
Switch presses {
Case 1: Send hk ; Single
Case 2: Send '+' hk ; Double
}
presses := 0
}
}
Re: Simple Double key tap and long press for same key
Thank you very much sir, really helpfulmikeyww wrote: ↑09 Jun 2023, 21:29Welcome to this AutoHotkey forum!
An example is below.
Code: Select all
#Requires AutoHotkey v2.0 $a:: { Static presses := 0, squelch := 300 hk := StrReplace(ThisHotkey, "$") ; Strip the dollar sign If KeyWait(hk, 'T.5') ; If key was quickly released, SetTimer(done, -squelch), presses++ ; then reset timer, and increment counter Else Send('+' hk), presses := -1 ; If held, send the shifted key done() { ; Key presses have ended Switch presses { Case 1: Send hk ; Single Case 2: Send '+' hk ; Double } presses := 0 } }
Re: Simple Double key tap and long press for same key
Thank you so much for this simple but elegant code!
Re: Simple Double key tap and long press for same key
I modified it to let me use Ctrl G as my hotkey as follows. Thanks for your willingness to help others!
Code: Select all
#Requires AutoHotkey v2.0
; single or double or long press
$^g::
{
Static presses := 0
squelch := 300 ;mSec between clicks in a double click -- they used 300
hk := StrReplace(ThisHotkey, "$") ; Strip the dollar sign
hk1:= SubStr(hk, 1, 1)
hk2:= SubStr(hk, 2, 1)
If KeyWait(hk1, 'T.5') and KeyWait(hk2, 'T.5') ; If key was quickly released,
{
SetTimer(done, -squelch)
presses++ ; then reset timer, and increment counter
}
Else
{
MsgBox "long press"
presses := -1
}
done()
{ ; Key presses have ended
Switch presses
{
Case 1: MsgBox "Single" ; Single
Case 2: MsgBox "Double" ; Double
}
presses := 0
}
}