Trigger every 15 minutes (relative to 00 minutes)

2020-05-06 18:19发布

问题:

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
...


标签: time autoit