Hey. So I'm running a script where if I press a key (F6), it runs a script indefinitely for a game. This script would have 2 SetTimer functions. One of them is a constant - every 11.5min it presses down on a key (BUFF function). Another SetTimer is random - every x seconds between two values (LOOP section), it activates a function that presses another key. Here is the code I currently have (assume the programid lines work):
Code: Select all
F6::
SetTimer, buff, 690000
;CONSTANT SECTION
BUFF:
ControlSend,,{g}, ahk_id %programid1%
sleep 500
return
;INTENDED TO PRESS THE SPACEBAR ONCE AFTER A RANDOM AMOUNT OF TIME HAS ELAPSED. CHANGES EVERYTIME THE SPACEBAR IS PRESSED
Loop
{
Random,x,60000,120000
ControlSend,,{Space}, ahk_id %programid1%,,,, NA
Sleep x
}
The problem with the current code is that the BUFF function runs, but the loop section doesn't. I tried using the Random in-built AHK function, but the way I implement it, the Randomized number is always the same. I know you can change it everytime if you put it in a loop, but I don't know how to do it and my attempt failed. How would I go about doing it such that when I press the F6 key, every 11.5min the BUFF function is run and after a random amount of time the Spacebar is pressed (the loop section).