Settimer Function with 2 Randoms

Ask gaming related questions (AHK v1.1 and older)
MyInnerMonk
Posts: 1
Joined: 06 Oct 2022, 20:14

Settimer Function with 2 Randoms

Post by MyInnerMonk » 06 Oct 2022, 20:30

Hey guys, i am sure the problem is simple but yet I still couldn't get my script to work properly.
First I want a script that is simple. Its for a situation in a game when I have to go afk for a bit but still want to continue with my work. It is simple: I want to press a specific button for a "random" time that release it make a break of some time with also a random inside. I dont know to explain it properly but simply both the time to hold the button down and the time to the next press should be both randomized

My Script looks like this

Code: Select all

Numpad0::
Send {E down}
sleep, Random, 250, 390
Send {E up}
Settimer, senden, 3150, 3820
Return

senden:
Send {E down}
sleep, Random, 250, 390
Send {E up}
Return
Numpad1::
Settimer, senden, off
Return
The script itself works the break of around 3 seconds works as well but the time the button is pressed doesnt work. Even when I put it to like 5000-7000 it will only press the button for a very short time. The problem is simple but it drives me nuts. I basicaly only want to press the E button for like the quarter of a second with different variants as well as the pausing for like 3 seconds will the next press. Don't get confused by the "senden" it is only a name.
I know the problem is very simple but i cant get it to work properly.

I would be happy for any help :)


[Mod actions: Moved topic to "Gaming", changed spoiler tags to code tags.]

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

Re: Settimer Function with 2 Randoms

Post by mikeyww » 06 Oct 2022, 20:57

Welcome to this AutoHotkey forum!

You cannot make up your own syntax. You have to use what AHK provides. See :arrow: Sleep for proper syntax. Sleep and Random are two different commands. Each command belongs on its own line. Random is not a function that returns a value per se. Instead, it populates an output variable that you specify. You can then use that variable in subsequent other commands.

Post Reply

Return to “Gaming Help (v1)”