魔导 发表于 2011-10-14 17:43:21

就用15楼的吧循环的{:1_498:}

魔导 发表于 2011-10-14 17:44:06

别忘了时间自己设一下{:1_498:}sleep(1000)=1秒

ylsfwb 发表于 2011-10-21 03:10:36

学习中~!~~~~~~

805333 发表于 2011-10-21 03:15:46

Opt("TrayMenuMode", 1)

#include <Date.au3>
#include <Misc.au3>
#include "Services.au3"
_Singleton(@ScriptName)
;如果已运行则退出
RegWrite('HKEY_CURRENT_USER\Control Panel\International', "sTimeFormat", "REG_SZ", "HH:mm:ss")
;注册表立即生效
DllCall("user32.dll", "int", "SendMessageTimeout", "hwnd", 65535, "int", 26, "int", 0, "int", 0, "int", 0, "int", 1000, "str", "dwResult")

$CFG_Path = @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".ini"

$sleephour = IniRead($CFG_Path, "参数设置", "重启间隔", "2")

If $sleephour < 0.02 Then $sleephour = 24

If $sleephour < 1 Then
        $nexthour = _DateAdd('n', Int($sleephour * 60), _NowCalc())
Else
        $nexthour = _DateAdd('h', $sleephour, _NowCalc())
EndIf


While 1
        Sleep(1000)
        time()
WEnd

Func time()
        $sleephour = IniRead($CFG_Path, "参数设置", "重启间隔", "2")
        If @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC = $nexthour Then
                If $sleephour < 1 Then
                        $nexthour = _DateAdd('n', Int($sleephour * 60), _NowCalc())
                Else
                        $nexthour = _DateAdd('h', $sleephour, _NowCalc())
                EndIf
                runp()
        EndIf

EndFunc   ;==>time

Func runp()
;在这里加入你想做的事
EndFunc   ;==>runp

Func exit_0()
        Exit
EndFunc   ;==>exit_0

lenlydia 发表于 2011-11-12 14:04:12

受教了。tks

yufei8051 发表于 2012-5-8 11:11:40

记号,学习了

yufei8051 发表于 2012-6-9 22:25:52

占用cpu比较多

fanxiang_1984 发表于 2013-2-6 10:07:06

记下!~{:face (356):}
页: 1 [2]
查看完整版本: 定时器怎么做呀