double and tripple tap of a key Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

double and tripple tap of a key

Post by Nod1234 » 13 Jan 2022, 01:44

Hey,
i want do following thing (row 2 out target with the target dimedelays):
grafik.png
grafik.png (5.13 KiB) Viewed 859 times
If i tap c key 1 times --> it should send c instant
If i tap c key 2 times --> it should send c instant and r (delayed due to function call)
If i tap c key 3 times --> it should send c instant and two times r (delayed due to function call)
If i hold down c key --> normal behavior (ccccccccc, instant)
My code up to now is that, which is more or less based on an example of AHK docu https://ahkde.github.io/docs/commands/SetTimer.htm#ExampleCount:

Code: Select all

$c::
send {c}
if (cKeyCount > 0)
{
cKeyCount += 1
return
}
cKeyCount := 1
SetTimer, cKey, -400
return

cKey:
send % cKeyCount = 2 ? "{r}" : "" ; double tap of c-key sends r-key 
send % cKeyCount = 3 ? "{r 2}" : "" ; tripple tap of c-key sends 2 x r-key 
cKeyCount := 0
return
My problem is that the script is now behaving like in row 3 (out actual), how can i change the script that it does what i want?
Thank you

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: double and tripple tap of a key  Topic is solved

Post by Xtra » 13 Jan 2022, 03:22

Give this a try:

Code: Select all

cKeyCount := 0

$c::
    if (cKeyCount > 0)
        cKeyCount += 1
    else
    {
        Send, c
        cKeyCount := 1
        
        KeyWait, c, T0.15
        if (ErrorLevel)
            while GetKeyState("c","P")
                Send, c
            
        SetTimer, cKey, -400
    }
return

cKey:
    Send, % cKeyCount = 2 ? "r" : cKeyCount = 3 ? "{r 2}" : ""
    cKeyCount := 0
return

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 13 Jan 2022, 04:06

Great! Thanks, this is exacly what i want.

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 13 Jan 2022, 11:10

Hey, i have to ask again something. I was testing my new code with the new implementation of the "dobble and tripple tap" functionality. But until that the code is sending somewhere the key {4} i dont find where the f**** this is coming from.
Is it possiple to finde out from which function / sub-function exaclty in the code is this coming from, from that history?
Image
Attachments
grafik.png
grafik.png (354.34 KiB) Viewed 778 times

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: double and tripple tap of a key

Post by Xtra » 13 Jan 2022, 11:16

Your larger script is probably causing an issue.
Look at the type column you can see it shows i for: i=Ignored because it was generated by an AHK script. (at top of image)

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 13 Jan 2022, 11:28

Does "i=Ignored because it was generated by an AHK script." mean, that key 4 wasnt sent? But i see the effect in the game, it was defenetly sent!

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: double and tripple tap of a key

Post by Xtra » 13 Jan 2022, 11:38

"it was generated by an AHK script." It was sent by a script you have running.

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 13 Jan 2022, 12:03

Hey,
i was looking at the code in detail and i found up to now only one part where this can happen:

Code: Select all

Send % LastBuildKey
Here a variable is beeing sent.
How do i implement a simple line for debugging and for proofing if "% LastBuildKey" is ever gonna be 4? Do you have an idea, maybe using Tooltip as keyhistory? is that possible?

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: double and tripple tap of a key

Post by Xtra » 13 Jan 2022, 12:06

Code: Select all

if (LastBuildKey = 4) {
    KeyHistory
    MsgBox, 4096, LastBuildKey, % LastBuildKey
}

Send % LastBuildKey

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 14 Jan 2022, 03:00

Hey Xtra,
i was implementing the diag in the script and checking the in game performance for more than a hour. Unfortunally the send 4 event didnt take place anymore but i am not shure and have my doubts if it is solved by itself!
In base it is hard for me to try out and force the "sending 4" event because its more or less random (because i still dont know exactly where its come from).
I will keep the diag code in my script for a while and continue playing with it, lets see if it will happen again.

Nod1234
Posts: 62
Joined: 13 Dec 2021, 12:10

Re: double and tripple tap of a key

Post by Nod1234 » 17 Jan 2022, 00:17

Hello again,
i was testing it for hours and it doesnt appear once! Seems it is solved but i still dont know how this was generated.
Thx

Post Reply

Return to “Gaming Help (v1)”