Slight issues with this code

Ask gaming related questions (AHK v1.1 and older)
Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Slight issues with this code

Post by Raiden96 » 06 Apr 2022, 08:34

As the title says i have small issues with the code below. What I want this script to do is to simply press F twice in a consecutive manner, of course, then hold the F for the 3rd time while pressing G only once. Tested the code in notepad and it only prints F twice, but not the 3rd F after holding it down for a couple hundred milliseconds. I'm not exactly sure what I'm missing. Any help would be greatly appreciated!

Code: Select all

G::
SetKeyDelay, 25, 25
SendInput,{f down}
SendInput,{f up}
SendInput,{f down}
Sleep 300
SendInput,{f up}
Return

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

Re: Slight issues with this code

Post by Xtra » 06 Apr 2022, 09:35

f down > f up > is sending f one time.
f down > sleep 300 > f up > is sending f one time.

You only have your script sending f a total of 2 times.
There is no sending g at all.

Add another send of f and g > then you will have a script that works the way you want.

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Slight issues with this code

Post by Raiden96 » 06 Apr 2022, 10:00

There is no sending g at all.
Add another send of f and g > then you will have a script that works the way you want.
I don't follow really. Where would send G even fit? G is supposed to be the trigger. Press G and it does the aforementioned stuff.
Can you show me exactly how this code should look like with the changes you suggested? I'd appreciate it greatly. Thank you!

Code: Select all

G::
SetKeyDelay, 25, 25
SendInput,{f down}
SendInput,{f up}
SendInput,{f down}
Sleep 300
SendInput,{f up}
SendInput,{f down}
SendInput,{f up}
Return

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

Re: Slight issues with this code

Post by Xtra » 06 Apr 2022, 10:37

then hold the F for the 3rd time while pressing G only once
It was not clear if you wanted to send g or not.

What you just posted looks like what you described if you do not want to send g. Does it not work?

Also note SetKeyDelay, 25, 25 does not work for SendInput. If you want certain sendInput lines to use SetKeyDelay change SendInput to Send on those lines.

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Slight issues with this code

Post by Raiden96 » 06 Apr 2022, 11:27

What you just posted looks like what you described if you do not want to send g. Does it not work?
Well not really. It does send the first 2 consecutive F's but i need the third one to be held down for half a second then released not simply pressed and released. Pressed and held down for a little while then released.

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

Re: Slight issues with this code

Post by Xtra » 06 Apr 2022, 11:34

Code: Select all

G::
SetKeyDelay, 25, 25
SendInput,{f down}
SendInput,{f up}
SendInput,{f down}
Sleep 300
SendInput,{f up}
SendInput,{f down}
Sleep, 500    ; < half second held on 3rd send of f
SendInput,{f up}
Return

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Slight issues with this code

Post by Raiden96 » 06 Apr 2022, 13:22

Thank you @Xtra!
Sadly still not working as intended. I think i should have been more specific regarding the combo i'm trying to pull. The F key is the melee key. By default in the game, while holding down F near an enemy you slash it 2 times with your knife and in order to pull the finisher combo, you have to hold down F immediately after the first 2 slashes for like half a second or almost a second then the enemy gets stunned and you can perform a finisher on it.
The odd thing is that the codes below actually work but not exactly in the way i intended for it to work.

For instance, if i hold down the G button manually, it executes the triple combo without fail every single time. What i really wanted was to simple press G and do the triple combo itself.
Weird is also the fact that if i only press G but not hold it down it does the first 2 knife slashes but doesn't hold down the last F for half a second.

Both this:

Code: Select all

G::
SetKeyDelay, 25, 25
SendInput,{f down}
SendInput,{f up}
SendInput,{f down}
Sleep 300
SendInput,{f up}
Return
and this:

Code: Select all

G::
SetKeyDelay, 25, 25
Send {f down}
Sleep 300
Send {f up}
Return
behave in the exact same manner. It pulls off the combo as long as i hold down G. If i tap it just once, it does the first 2 knife slashes without the gun butt hit that stuns the target and allows for a finisher.
In truth, i do have a working solution, only with a slight inconvenience if it can be called that. It would be great if i could get it to work the way i want it, but if not then i suppose i could live with this small inconvenience. It's not that big of a deal after all. But i'd like to get to the bottom of this if possible.

Post Reply

Return to “Gaming Help (v1)”