Autoit script on specific actual time

↘锁芯ラ 提交于 2019-12-13 11:15:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!