Autoit script on specific actual time

2019-09-25 10:50发布

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.

标签: time autoit
2条回答
smile是对你的礼貌
2楼-- · 2019-09-25 11:35

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.

查看更多
聊天终结者
3楼-- · 2019-09-25 11:40

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
查看更多
登录 后发表回答