本帖最后由 afan 于 2020-8-7 18:25 编辑 #include <Date.au3>
Local $sTimes = InputBox('预约', '请输入测试物品的启动时间(时分秒)')
If @error Then Exit
Local $aTimes = StringRegExp($sTimes, '(\d\d?)\D+(\d\d?)\D+(\d\d?)', 1) ;带分隔符3段时间
If @error Then
$aTimes = StringRegExp($sTimes, '(\d\d)(\d\d)(\d\d)', 1) ;不带分隔符6位数时间
If @error Then Exit MsgBox(48, '', '时间格式错误')
EndIf
If $aTimes[2] = '' Then $aTimes[2] = '00'
$sTimes = StringFormat('%s/%s/%s %s:%s:%s', @YEAR, @MON, @MDAY, $aTimes[0], $aTimes[1], $aTimes[2])
Local $iDateCalc = _DateDiff('s', _NowCalc(), $sTimes) ;获取当前时间,并计算当前时间与设定时间的差值
Local $iTs = TimerInit()
If $iDateCalc > 10 Then Sleep(($iDateCalc - 10) * 1000)
Do
Sleep(250)
Until TimerDiff($iTs) >= $iDateCalc * 1000
MsgBox(0, $sTimes, '时间到')
;~ Run('C:\Program Files (x86)\?\?.exe') ;到达设定时间点打开软件
|