Press two keys for one hotkey

Ask gaming related questions (AHK v1.1 and older)
shanshans
Posts: 27
Joined: 13 Dec 2015, 08:10

Press two keys for one hotkey

Post by shanshans » 03 May 2022, 12:25

Sorry for my english

I need a script to do something like this...

Tap A and B at the same time will output C and only C ,C will keep the holding state when A and B are both still pressed down until one of them are released.

A/B will only wait for the other to be pressed down for 15ms, longer than that will not output C , just output A/B normally in-between.

A and B will function normally like the others keys (hold, up, down) , until triggered.

I hope someone can answer this , this sound easy but bother me for a long time... thks

Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Press two keys for one hotkey

Post by Rohwedder » 04 May 2022, 03:33

Hallo,
try:

Code: Select all

Ta := Tb := 0
#IF !GetKeyState("c")
$*a::
$*b::
AB := SubStr(A_ThisHotkey,0), T%AB% := A_TickCount
SetTimer, AB, -15
Return
AB:
Send,% "{Blind}{" (Abs(Ta-Tb)<15?"c Down}":AB " Down}")
Return
#IF GetKeyState("c")
*a Up::
*b Up::Send, {Blind}{a Up}{b Up}{c Up}
#IF
~*a Up::
~*b Up::Return
If the key C should do AutoRepeat it would still need a corresponding Timer.

shanshans
Posts: 27
Joined: 13 Dec 2015, 08:10

Re: Press two keys for one hotkey

Post by shanshans » 06 May 2022, 13:54

Sorry for the later reply, the site doesn't give me any notification...

Another ahk people send me a script that almost solved my question
https://www.autohotkey.com/board/topic/40874-chording-script/

This one gave me the best result so far ,the game will understand all the output like normal, every keys state are correct, but it share the same pass through error with your script.

Which is when you hold a/b long enough then press the other key, c will be outputted. That is incorrect , because the pressing time is already over 15ms. If you know how to fixed his script plz let me know :)
Anyway, thks.

Post Reply

Return to “Gaming Help (v1)”