0

I have always used autoIt for windows for this but i need to do it on ubuntu or centOS now. Basicly what i want is to send an mouseclick or button after an randomized time example:

~

HotKeySet("{ESC}", "Terminate") ; hotkey for stopping script

While 1
 Sleep(Random(120000, 180000)) ;waits random between 2 and 3 minutes before sending a left mouse click 
 MouseClick("Left")
 Sleep(Random(60000, 120000)) ; wait random between 1 and 2 minutes to send O
 Send("O")
 Sleep(Random(10000, 20000)) ; waits random between 10 and 20 seconds to send a left mouse click
 MouseClick("Left")
WEnd

Func Terminate()
 Exit
EndFunc

~

is there an program wich can do this? i have looked around but i couldn't find something i can understand. Thanks in advance

  • If you are looking for something similar to autoit, you may want to take a look at AutoKey. – danzel May 17 '19 at 12:25
  • @pLumo iv'e found those two earlyer today but i don't think or atleast i cannot find information on it to make random time intervals – RapidGainz May 17 '19 at 12:33
  • See https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash/1195035 and combine the information ... – pLumo May 17 '19 at 12:37
  • @pLumo is that possible combining bash with xdotools? – RapidGainz May 17 '19 at 12:41
  • you should read more than just the first sentence of the first answer ... there is a while-loop with sleep 5, change the 5 with random number and you're fine. – pLumo May 17 '19 at 12:42
  • @pLumo something like this?

    ~ #!/bin/bash while [ 1 ]; do xdotool click 1 & sleep $ echo $((60 + RANDOM % 120)) done ~ ?

    – RapidGainz May 17 '19 at 12:59
  • echo will print the value, you want to add it directly to sleep: sleep $((60 + RANDOM % 120));. – pLumo May 17 '19 at 13:07
  • @pLumo thanks dude! it works but i made it random between 10 and 20 seconds and allot of times it disregards the limit of 20 seconds and goes beyond that.How is that possible? – RapidGainz May 17 '19 at 13:40

1 Answers1

0

In Linux you usually use a bash script to do something like this. In order to get a mouse click, you need to install xdotool:

sudo apt install xdotool

Now, you can write a simple bash-script. Just run

nano bash_script.sh

Now paste following code:

#!/bin/bash
while true
do
  sleep $((120 + RANDOM % 60))
  xdotool click 1
  sleep $((60 + RANDOM % 60))
  echo '0'
  sleep $((10 + RANDOM % 10))
  xdotool click 1
done

Run sudo chmod u+x bash_script.sh in order to make your script executable. Last, you can start your script with

sh bash_script.sh
prog2de
  • 133