Send multiple text within an interval of time Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
KILIGON
Posts: 4
Joined: 26 May 2023, 20:30

Send multiple text within an interval of time

Post by KILIGON » 26 May 2023, 20:40

Hi all,
Been learning to use authotkey and this is my first script after using many solutions found either here and reddit and I would really appreciate help on this problem

Objetive: I'm trying to send multiple text (number format) within the specified interval on time. First send 9,8 and 0 at the same time (maybe having a delay of 1-2 seconds from each, to seem human and not a bot) and afterwards start using the "delay2" of each of their number, repeating until stopping.

Problem: When I start the script it press number 9 and when the delay finishes it will continue to press the other numbers until the cycle is completed and start again at 9.

Let me know if I was not clear.


Code: Select all

F7::

if (enable := !enable)
    setTimer, routine, -1

return

routine:
while enable

{
{
    Random, delay1, 500, 550     
    Random, delay2, 425000, 500000
    send, {9 down}
    Sleep %delay1%
    Send {9 up}
    Sleep, %delay2%
}
    
    Random, delay1, 500, 550 
    Random, delay2, 19000, 27500
    send, {8 down}
    Sleep %delay1%
    Send {8 up}
    sleep, %delay2%
}

    Random, delay1, 500, 550  
    Random, delay2, 380000, 520000
    send, {0 down}
    Sleep %delay1%
    Send {0 up}
    sleep, %delay2%
}
}

return 

F8::
Suspend ;Suspend Hotkeys off/on
Pause,, 1 ;Pause Script off/on
Return
[Mod edit: [code][/code] tags added. Please use them yourself going forward.]
[Mod edit: Moved topic to AHK v1 help, since this is not v2 code.]

Rohwedder
Posts: 7689
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send multiple text within an interval of time

Post by Rohwedder » 27 May 2023, 04:45

Hallo,
try:

Code: Select all

F7::
enable := !enable
SetTimer, T9,% enable?-100:"Off"
SetTimer, T8,% enable?-200:"Off"
SetTimer, T0,% enable?-300:"Off"
Return
T9:
send, {9 down}
Sleep, Rand(500, 550)
Send, {9 up}
SetTimer,,% -Rand(425000, 500000)
Return
T8:
send, {8 down}
Sleep, Rand(500, 550)
Send, {8 up}
SetTimer,,% -Rand(19000, 27500)
Return
T0:
send, {0 down}
Sleep, Rand(500, 550)
Send, {0 up}
SetTimer,,% -Rand(380000, 520000)
Return
F8::
Suspend ;Suspend Hotkeys off/on
Pause,, 1 ;Pause Script off/on
Return
Rand(Min:="", Max:="")
{
	Random, Rand, Min, Max
	Return, Rand
}

KILIGON
Posts: 4
Joined: 26 May 2023, 20:30

Re: Send multiple text within an interval of time

Post by KILIGON » 27 May 2023, 07:54

Thanks a lot!
It worked perfectly. I will keep improving it. I understand now the set timer linking with T9, T8 and T0. :D :D

KILIGON
Posts: 4
Joined: 26 May 2023, 20:30

Re: Send multiple text within an interval of time

Post by KILIGON » 27 May 2023, 08:51

Hi Rohwedder,

When I tried improving the script and I wanted to set a time to force exit app once X time has passed at a random interval. At first I thought it work but then reading SetTimer will make excute the action and later start the timing. Is there a way to disabel the first timer and later starting it.

ANother option I thought was using Set timmer, T2 (which will be the one for exiting) however I do not know how to add it to the script.

it would be really help full if you can lend me some help please or guide me a bit.

Code: Select all

F7::
enable := !enable
SetTimer, T9,% enable?-100:"Off"
SetTimer, T8,% enable?-200:"Off"
SetTimer, T0,% enable?-300:"Off"
SetTimer, ForceExitApp,,% -Rand(5220000, 6120000)
Return
T9:
send, {9 down}
Sleep, Rand(500, 550)
Send, {9 up}
SetTimer,,% -Rand(425000, 500000)
Return
T8:
send, {8 down}
Sleep, Rand(500, 550)
Send, {8 up}
SetTimer,,% -Rand(19000, 27500)
Return
T0:
send, {0 down}
Sleep, Rand(500, 550)
Send, {0 up}
SetTimer,,% -Rand(380000, 520000)
Return
F8::
Suspend ;Suspend Hotkeys off/on
Pause,, 1 ;Pause Script off/on
Return
Rand(Min:="", Max:="")
{
	Random, Rand, Min, Max
	Return, Rand
}

ForceExitApp:
SetTimer,  ForceExitApp, Off
ExitApp
[Mod edit: [code][/code] tags added.]

gregster
Posts: 9068
Joined: 30 Sep 2013, 06:48

Re: Send multiple text within an interval of time

Post by gregster » 27 May 2023, 08:55

@KILIGON, please use code tags going forward. Thank you!

Rohwedder
Posts: 7689
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send multiple text within an interval of time  Topic is solved

Post by Rohwedder » 27 May 2023, 09:26

Perhaps:

Code: Select all

SetTimer,  ForceExitApp,% 3600*Rand(1000, 2000) ;Ends script after 1 to 2 hours
F7::
enable := !enable
SetTimer, T9,% enable?(T:=Rand(600, 700)):"Off"
SetTimer, T8,% enable?(T+=Rand(600, 700)):"Off"
SetTimer, T0,% enable?(T+=Rand(600, 700)):"Off" ;9, 8, 0 are initially sent one after the other
Return
T9:
send, {9 down}
Sleep, Rand(500, 550)
Send, {9 up}
SetTimer,,% Rand(425000, 500000)
Return
T8:
send, {8 down}
Sleep, Rand(500, 550)
Send, {8 up}
SetTimer,,% Rand(19000, 27500)
Return
T0:
send, {0 down}
Sleep, Rand(500, 550)
Send, {0 up}
SetTimer,,% Rand(380000, 520000)
Return
ForceExitApp:
ExitApp
Return
F8::
Suspend ;Suspend Hotkeys off/on
Pause,, 1 ;Pause Script off/on
Return
Rand(Min:="", Max:="")
{
	Random, Rand, Min, Max
	Return, Rand
}

KILIGON
Posts: 4
Joined: 26 May 2023, 20:30

Re: Send multiple text within an interval of time

Post by KILIGON » 27 May 2023, 12:29

Thanks a lot @Rohwedder you are a master!! I've tested it few times and got no problem

I'm still learning but what's the purposed of T:= and T+= ?. How does AHK knows that one action needs to be one to another

SetTimer, T9,% enable?(T:=Rand(600, 700)):"Off"
SetTimer, T8,% enable?(T+=Rand(600, 700)):"Off"
SetTimer, T0,% enable?(T+=Rand(600, 700)):"Off" ;9, 8, 0 are initially sent one after the other


@gregster I will! :)

Rohwedder
Posts: 7689
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send multiple text within an interval of time

Post by Rohwedder » 27 May 2023, 13:17

To make sure that the three Timer ignite cascaded, i.e. not overlapping, the TriggerTime, =Rand(...), of T9 is stored in the variable T. The trigger time of T8 is then this T increased by Rand(...) and the trigger time of T0 is then is T increased a third time by Rand(...).
I hope you understand me. It is easier to write this in Autohotkey than in English!

Post Reply

Return to “Ask for Help (v1)”