How to set tapping and double tapping on one key to trigger different functions?

Ask gaming related questions
Ransom
Posts: 8
Joined: 22 Jul 2020, 22:44

How to set tapping and double tapping on one key to trigger different functions?

25 Jul 2020, 00:38

Hi community:
I am trying to set tapping and double tapping on LAlt key to trigger different functions. My single tap function is like below:

Code: Select all

~LAlt::
; If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
; {
; 	sendinput, {NumpadDiv} ;double tapping function
; }

sendinput, {Numpad2}{Home Down} ;single tapping function

keywait, LAlt

sendinput, {End down}{Home Up} ;single tapping function
sleep 500
sendinput, {End up}
}
Return
The commented line at the beginning (that less than 400 if condition) is my attempt to set up double taps.
This code doesnt work because the "sleep 500" command near the end of the code will make the time between two LAlt key presses greater than 500, thus that "less than 400" condition is never met.
Even I lessen the condition to be for example 600, it still won't work in fast double tapping scenario, since less than 500 mil seconds fast double tapping will still be blocked by that "sleep 500" command.
Can anyone teach me to kick of a thread where double tapping evaluation is done in a paralle thread? Or teach me a way to start a parallel processing thread on that "sleep 500" command so it won't block another fast LAlt press?
Thanks!
Ransom
Posts: 8
Joined: 22 Jul 2020, 22:44

Re: How to set tapping and double tapping on one key to trigger different functions?

25 Jul 2020, 16:07

since nobody answered I figured it out myself.
Instead of using sleep, I should just use Settimer.
Here are the code that should replace the sleep part:

Code: Select all

send, {End Down}{Home Up}
; sleep 100
SetTimer, EndUp, 200
Return
; sendinput, {End up}

EndUp:
send, {End Up}
Return

Return to “Gaming”

Who is online

Users browsing this forum: tahtinen62, Xtra and 10 guests