I want my AutoIt script to run every 20 minutes without using Sleep()
. I cannot buy any software; is there freeware which can do this?

- 2,809
- 13
- 27
- 42

- 7
- 1
- 2
-
[Related](https://stackoverflow.com/a/48853242/4157124). – user4157124 Jul 30 '19 at 13:42
-
[Related](https://stackoverflow.com/a/29480070/4157124). – user4157124 Jul 30 '19 at 13:55
-
[Related](https://stackoverflow.com/q/52957158/4157124). – user4157124 Aug 10 '19 at 13:27
5 Answers
Have you tried Task Scheduler on windows? (it's built-in most of windows versions) It depends on your windows version, but if you set up an advanced task, you can make it run every x minutes

- 23
- 3
Well actually you can do this in various ways with autoit too... I don't know if with "no sleep" you mean you don't want to keep the program open. If so, you can write your own autoit program to run your .exe autoit script every 20 mins.
Or you can do it in your own script by checking the system clock.

- 11
- 1
- 2
Sleep()
is important if you want the script to be running constantly. You can do something like this to get a 20 minute wait:
While 1
$timer = TimerInit()
Do
If TimerDiff($timer) > 1200000 Then
MsgBox (0,"Timer Alert","The timer has hit 20 minutes!")
EndIf
Until TimerDiff ($timer) > 1200000
WEnd
Without Sleep()
at all, it's going to be eating up a good amount of CPU since it's checking the timer as fast as it possibly can. Plus, you run a very small chance being at 1199999 ms when the first IF
checks, and being at 1200001 when it evaluates the Until
and it would skip the message.
Your best bet is to just make your script do whatever, then use Windows Task Scheduler to run every 20 minutes. Though when I checked, there's no option for every 20 minutes.

- 1,048,767
- 296
- 4,058
- 3,343

- 7,995
- 2
- 13
- 6
Use _Timer_SetTimer()
to set a timer you want without Sleep()
.

- 2,809
- 13
- 27
- 42

- 9
- 1