特定实际时间的自动脚本

问题描述 投票:-3回答:2

如何在Autoit中的特定实际时间运行脚本? 例如,我随时启动自动脚本,它等到我定义的时间(例如01:00:00和02:00:00&...)到达,然后脚本恢复并做我想要的任何事情。 抱歉我的语言不好。

time autoit
2个回答
0
投票

假设您希望脚本在22:31:15发出哔声:

While 1
Sleep(250)
If @HOUR == 22 And @MIN == 31 And @SEC == 15 Then
    Beep(500,500)
EndIf
WEnd

0
投票

以下代码设置不同的时间(多小时,多分钟和多秒)以执行您的脚本:

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

您可以通过按F10键退出_exit()函数。

© www.soinside.com 2019 - 2024. All rights reserved.