windows 每 20 分钟运行一次脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4828247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run script every 20 minutes
提问by bloody mary
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?
我希望我的 AutoIt 脚本每 20 分钟运行一次而不使用Sleep()
. 我不能购买任何软件;有没有可以做到这一点的免费软件?
回答by olivarra1
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
您是否在 Windows 上尝试过任务计划程序?(它内置于大多数 Windows 版本中)这取决于您的 Windows 版本,但如果您设置了高级任务,您可以让它每 x 分钟运行一次
回答by u830089
see AdlibRegisterfunction in autoit help
请参阅 autoit 帮助中的AdlibRegister函数
回答by Gbgf Ggf
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.
嗯,实际上你也可以用 autoit 以各种方式做到这一点......我不知道“不睡觉”是否意味着你不想让程序保持打开状态。如果是这样,您可以编写自己的 autoit 程序,每 20 分钟运行一次 .exe autoit 脚本。
Or you can do it in your own script by checking the system clock.
或者您可以通过检查系统时钟在您自己的脚本中执行此操作。
回答by necu
Use _Timer_SetTimer()
to set a timer you want without Sleep()
.
使用_Timer_SetTimer()
设置要没有一个计时器Sleep()
。
回答by Eremite
Sleep()
is important if you want the script to be running constantly. You can do something like this to get a 20 minute wait:
Sleep()
如果您希望脚本持续运行,这一点很重要。你可以做这样的事情来等待 20 分钟:
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.
Sleep()
根本没有,它将消耗大量 CPU,因为它会尽可能快地检查计时器。另外,您在第一次IF
检查时运行在 1199999 毫秒处的机会很小,而在评估时运行在 1200001处Until
,它将跳过该消息。
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.
你最好的办法是让你的脚本做任何事情,然后使用 Windows 任务计划程序每 20 分钟运行一次。虽然当我检查时,每 20 分钟就没有选项。