问题
How to run a script on specific actual time's in Autoit?
for example I start Autoit script at any time and it wait until my defined time (e.g. 01:00:00 & 02:00:00 & ...) reach's and then script resume and do any thing i want.
sorry for my poor language.
回答1:
Say you want your script to beep at 22:31:15 then:
While 1
Sleep(250)
If @HOUR == 22 And @MIN == 31 And @SEC == 15 Then
Beep(500,500)
EndIf
WEnd
回答2:
Following code sets different times (multiple hours, multiple minutes and multiple seconds) to execute your script at:
HotKeySet('{F10}', '_exit')
Func _exit()
Exit
EndFunc
While 1
Global $bIsHour = False
Global $bIsMinutes = False
Global $bIsSeconds = False
; check multiple hours
Switch Int(@HOUR)
Case 8, 15, 22
$bIsHour = True
; check multiple minutes
Switch Int(@MIN)
Case 20, 22, 30
$bIsMinutes = True
; check multiple seconds
Switch Int(@SEC)
Case 15, 55
$bIsSeconds = True
EndSwitch
EndSwitch
EndSwitch
If $bIsHour And $bIsMinutes And $bIsSeconds Then
; do your actions ...
ConsoleWrite('Time matches!' & @CRLF)
EndIf
Sleep(600)
WEnd
You can exit the loop by pressing F10 for the _exit()
function.
来源:https://stackoverflow.com/questions/52957158/autoit-script-on-specific-actual-time