Looking for help with a script

Ask gaming related questions (AHK v1.1 and older)
Moongoose
Posts: 5
Joined: 22 Aug 2023, 04:11

Looking for help with a script

28 Apr 2024, 12:40

Hello everyone,

I am new to AHK and trying to write a script that executes the following:

Pressing the r button sends r normally, but after pressing it, for 20 seconds pressing r sends x instead.

Since all my attemts do not work, i wanted to ask, if anybody could help me with this script.

Thanks alot in advance and have a nice day!
User avatar
mikeyww
Posts: 28872
Joined: 09 Sep 2014, 18:38

Re: Looking for help with a script

28 Apr 2024, 19:02

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33.11

$r::
end := A_TickCount + 20000
SetKeyDelay 25, 25
While GetKeyState("r", "P")
 SendEvent % A_TickCount < end ? "r" : "x"
Return
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.
Moongoose
Posts: 5
Joined: 22 Aug 2023, 04:11

Re: Looking for help with a script

29 Apr 2024, 05:40

Hello and thanks alot for the help!

I do not know if i am doing something wrong, but when i run the script it just sends two r presses when i press r and never sends x. Is there something i am doing wrrong?

Thanks alot forr the help, i will also check out v2.
User avatar
mikeyww
Posts: 28872
Joined: 09 Sep 2014, 18:38

Re: Looking for help with a script

29 Apr 2024, 06:07

Test in Notepad.

What the script does:
Pressing the r button sends r normally, but after pressing it, for 20 seconds pressing r sends x instead.
If you wish, change the number in the script. The number of milliseconds is shown there on line 4.
Moongoose
Posts: 5
Joined: 22 Aug 2023, 04:11

Re: Looking for help with a script

29 Apr 2024, 06:17

Hmm sorry maybe i did not make clear what i want the script to do. Sorry english is not my native language.

Id like the script to do the following: After pressing and sending r, for a period of 20 seconds, pressing r will only send x. Notepad should like this:
rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (20sec) rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (20sec) ....

Sorry for my miscommunication and thanks alot for all the help!
User avatar
mikeyww
Posts: 28872
Joined: 09 Sep 2014, 18:38

Re: Looking for help with a script

29 Apr 2024, 07:01

You have the tools here, so with your interest in writing a script, you can start to adjust the code to match your description. The revised script below is a start.

Code: Select all

#Requires AutoHotkey v1.1.33.11

$r::
SetKeyDelay 25, 25
While GetKeyState("r", "P") {
 SendEvent r
 end := A_TickCount + 20000
 While GetKeyState("r", "P") && A_TickCount < end
  SendEvent x
}
Return
tabr3
Posts: 51
Joined: 25 Feb 2024, 04:06

Re: Looking for help with a script

30 Apr 2024, 12:31

Moongoose wrote:
29 Apr 2024, 06:17
Hmm sorry maybe i did not make clear what i want the script to do. Sorry english is not my native language.

Id like the script to do the following: After pressing and sending r, for a period of 20 seconds, pressing r will only send x. Notepad should like this:
rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (20sec) rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (20sec) ....

Sorry for my miscommunication and thanks alot for all the help!
If i guessing correctly , what you're asking is to replace "r" with "x" during the period of "CD timing". r(2nd) will not be output again whether it is pressing , holding or tapping(released).

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 38 guests