D
D
desmonddd2021-08-17 17:21:23
autohotkey
desmonddd, 2021-08-17 17:21:23

How to make a keypress within a time range?

I need help writing a script.
I need a key to be pressed within a certain range of time, for example from 15 seconds to 20, etc.
So that the time is chosen randomly.
There is such code:

!1: :
loop
{
SendInput, { E } ;
sleep 17000
}
return

!2: :
pause

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vehs, 2021-09-07
@Vehs

; рандомизация времени нажатия для сходства с человеком
F1::
Loop
{
Random, rand1, 150, 300     ; переменная со случайным значением от 150 до 300 мс
Random, rand2, 1000, 10000    ; аналогично от 1 до 10 секунд
Send {F5 Down}
sleep, rand1
Send {F5 Up}
sleep, rand2
}

F2::
  Exitapp

In your case it will be something like this:
spoiler
!1: :
loop
Random, rand1, 15000, 20000
{
SendInput, { E } ;
sleep rand1
}
return
!2: :
pause

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question