Need help with script that automatics clicks arrow-keys Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Need help with script that automatics clicks arrow-keys  Topic is solved

Post by Alex5000 » 01 Apr 2022, 12:40

Hello,

I'm in search of a script that can automatic click arrow keys in order, it's for a game :twisted:

The list of the arrow keys is listed as follow:

"1.downrightdown
4.downrightright
7.rightdownleft
10.uprightup
13.upupleft
16.downleftdown
19.rightdownleft
22.upupup
25.rightdownright
28.downleftleft
31.leftleftdown
34.downrightup
37.rightdownright
40.upupleft
and more..."

how can i make it that it automaticly click arrow keys from up to down, so in this case": down, right, down , down , right, right etc
Is it also possible to make a "random" amount of ms between the keyclicks?

Sorry for the confusing question. :crazy:

User avatar
mikeyww
Posts: 26593
Joined: 09 Sep 2014, 18:38

Re: Need help with script that automatics clicks arrow-keys

Post by mikeyww » 01 Apr 2022, 13:20

Code: Select all

F3:: ; F3 = Trigger this subroutine
Send {Down}{Right}{Down}
Random, rand, 15, 150
Sleep, rand
Send {Down}{Right 2}
Return

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 16 May 2022, 14:13

mikeyww wrote:
01 Apr 2022, 13:20

Code: Select all

F3:: ; F3 = Trigger this subroutine
Send {Down}{Right}{Down}
Random, rand, 15, 150
Sleep, rand
Send {Down}{Right 2}
Return
Thank you!
Do you know how to add random delay to every button instead of adding "Random, rand, 15, 150" to each line?
So i can paste comething like this:

Code: Select all

{Left}{Left}{Down}
{Right}{Down}{Right}
{Up}{Left}{Down}
{Left}{Up}{Right}
{Right}{Down}{Left}
{Up}{Up}{Left}
{Down}{Down}{Right}
{Right}{Up}{Left}
{Down}{Left}{Up}
{Right}{Right}{Down}
{Left}{Down}{Right}
{Up}{Up}{Left}
{Down}{Right}
and every key will be randomized?

User avatar
mikeyww
Posts: 26593
Joined: 09 Sep 2014, 18:38

Re: Need help with script that automatics clicks arrow-keys

Post by mikeyww » 16 May 2022, 14:52

Code: Select all

str =
(
{Left}{Left}{Down}
{Right}{Down}{Right}
{Up}{Left}{Down}
{Left}{Up}{Right}
{Right}{Down}{Left}
{Up}{Up}{Left}
{Down}{Down}{Right}
{Right}{Up}{Left}
{Down}{Left}{Up}
{Right}{Right}{Down}
{Left}{Down}{Right}
{Up}{Up}{Left}
{Down}{Right}
)
For each, key in StrSplit(Trim(str, "{"), "{", "`n}") {
 Random, rnd, 15, 150
 Send {%key%}
 Sleep, rnd
}
MsgBox, 64, Done, Done!

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 23 May 2022, 12:18

mikeyww wrote:
16 May 2022, 14:52

Code: Select all

str =
(
{Left}{Left}{Down}
{Right}{Down}{Right}
{Up}{Left}{Down}
{Left}{Up}{Right}
{Right}{Down}{Left}
{Up}{Up}{Left}
{Down}{Down}{Right}
{Right}{Up}{Left}
{Down}{Left}{Up}
{Right}{Right}{Down}
{Left}{Down}{Right}
{Up}{Up}{Left}
{Down}{Right}
)
For each, key in StrSplit(Trim(str, "{"), "{", "`n}") {
 Random, rnd, 15, 150
 Send {%key%}
 Sleep, rnd
}
MsgBox, 64, Done, Done!
Thanks but i have no idea how i make that work with the script you posted :oops: :crazy:

User avatar
mikeyww
Posts: 26593
Joined: 09 Sep 2014, 18:38

Re: Need help with script that automatics clicks arrow-keys

Post by mikeyww » 23 May 2022, 12:23

The way to make it work is to run the script!

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 23 May 2022, 12:43

mikeyww wrote:
23 May 2022, 12:23
The way to make it work is to run the script!
Oh wow i didn't see the bottom :headwall: , it works very well now thank you very much! :dance:

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 25 May 2022, 13:27

mikeyww wrote:
16 May 2022, 14:52

Code: Select all

str =
(
{Left}{Left}{Down}
{Right}{Down}{Right}
{Up}{Left}{Down}
{Left}{Up}{Right}
{Right}{Down}{Left}
{Up}{Up}{Left}
{Down}{Down}{Right}
{Right}{Up}{Left}
{Down}{Left}{Up}
{Right}{Right}{Down}
{Left}{Down}{Right}
{Up}{Up}{Left}
{Down}{Right}
)
For each, key in StrSplit(Trim(str, "{"), "{", "`n}") {
 Random, rnd, 15, 150
 Send {%key%}
 Sleep, rnd
}
MsgBox, 64, Done, Done!
Is there also a way to add random delay (between 80 ms and 130 for an example for each key)which how long a key is pressed? on https://blog.seethis.link/scan-rate-estimator/ it says 1ms what impossible is to do with a "real" keyboard
I really appreciate your help

User avatar
mikeyww
Posts: 26593
Joined: 09 Sep 2014, 18:38

Re: Need help with script that automatics clicks arrow-keys

Post by mikeyww » 25 May 2022, 13:58

Yes. See https://www.autohotkey.com/docs/commands/Send.htm#Repeating_or_Holding_Down_a_Key
You can then generate a new Random number and use it for a new Sleep. An alternative is SetKeyDelay.

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 25 May 2022, 14:03

mikeyww wrote:
25 May 2022, 13:58
Yes. See https://www.autohotkey.com/docs/commands/Send.htm#Repeating_or_Holding_Down_a_Key
You can then generate a new Random number and use it for a new Sleep. An alternative is SetKeyDelay.
I don't know how i can add that to the script, sorry :cry:

User avatar
mikeyww
Posts: 26593
Joined: 09 Sep 2014, 18:38

Re: Need help with script that automatics clicks arrow-keys

Post by mikeyww » 25 May 2022, 14:28

Code: Select all

For each, key in StrSplit(Trim(str, "{"), "{", "`n}") {
 Random, pressDuration, 15, 150
 Random, afterRelease , 15, 150
 SetKeyDelay, afterRelease, pressDuration
 Send {%key%}
}

Alex5000
Posts: 7
Joined: 01 Apr 2022, 12:34

Re: Need help with script that automatics clicks arrow-keys

Post by Alex5000 » 30 May 2022, 13:09

mikeyww wrote:
25 May 2022, 14:28

Code: Select all

For each, key in StrSplit(Trim(str, "{"), "{", "`n}") {
 Random, pressDuration, 15, 150
 Random, afterRelease , 15, 150
 SetKeyDelay, afterRelease, pressDuration
 Send {%key%}
}
Yes! Works great! Thanks again and have a nice day :D

Post Reply

Return to “Gaming Help (v1)”