Trigger every 15 minutes (relative to 00 minutes)

人盡茶涼 提交于 2019-12-31 05:15:06

问题


Using AutoIt, how to perform some action when time is at xx:00, xx:15, xx:30 and xx:45 (every 15min) by recognizing the actual time?


回答1:


Sleep(1000 * 60 * 15) may be used. Example as per:

"by recongnizing the actual time"

-requirement (using Mod() and @MIN -macro) :

Global Const $g_iInterval = 15
Global Const $g_iDelay    = 10
Global Const $g_sMsg      = 'Triggered at %s:%s\n'

Global       $g_sLast     = ''

While True

    If Not (@MIN = $g_sLast) And Mod(Int(@MIN), $g_iInterval) = 0 Then

        $g_sLast = @MIN
        ConsoleWrite(StringFormat($g_sMsg, @HOUR, @MIN))

    EndIf

    Sleep($g_iDelay)

WEnd

Console output:

Triggered at 00:00
Triggered at 00:15
Triggered at 00:30
Triggered at 00:45
Triggered at 01:00
Triggered at 01:15
Triggered at 01:30
Triggered at 01:45
...


来源:https://stackoverflow.com/questions/51445735/trigger-every-15-minutes-relative-to-00-minutes

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