我有一个自动脚本,双击它会显示总时间(例如我在办公室的时间)。现在我希望我的脚本在3个小时之后弹出,没有我的互动。这是我的脚本。
#include <Date.au3>
Global $ini = "ini.ini"
If _AlreadyRunToday() Then
MsgBox (0, "Total hours", _Format(_Diff()))
Else
__SetTime()
EndIf
__SetDate()
Func _AlreadyRunToday()
If IniRead($ini, "Section", "D", "") <> @MDay _
Or IniRead($ini, "Section", "M", "") <> @Mon _
Or IniRead($ini, "Section", "Y", "") <> @Year Then Return False
Return True
EndFunc
Func _ReadDate() ;Returns the time when the program run the first time in YYYY/MM/DD HH:MM:SS
Return IniRead($ini, "Section", "Y", "") & "/" & IniRead($ini, "Section", "M", "") & "/" & IniRead($ini, "Section", "D", "") & " " & IniRead($ini, "Section", "H", "") & ":" & IniRead($ini, "Section", "Mi", "") & ":" & IniRead($ini, "Section", "S", "")
EndFunc
Func __SetDate() ;Sets the date the program run the last time
IniWrite($ini, "Section", "D", @MDay)
IniWrite($ini, "Section", "M", @Mon)
IniWrite($ini, "Section", "Y", @Year)
EndFunc
Func __SetTime() ;Sets the time of the first instance running that day
IniWrite($ini, "Section", "H", @Hour)
IniWrite($ini, "Section", "Mi", @Min)
IniWrite($ini, "Section", "S", @Sec)
EndFunc
Func _Diff() ;Calculates the seconds passed since the first run today
Return _DateDiff("s", _ReadDate(), _NowCalc())
EndFunc
Func _Format($Seconds)
Local $h, $m, $s
_TicksToTime($Seconds * 1000, $h, $m, $s)
;Return $h & ":" & $m & ":" & $s
Return StringFormat("%02d:%02d:%02d", $h, $m, $s)
EndFunc
我想知道这件事。谢谢。
答案 0 :(得分:0)
你走了。 它会每3小时通知您一次。
#include <Date.au3>
Global $ini = "ini.ini"
If _AlreadyRunToday() Then
MsgBox (0, "Total hours", _Format(_Diff()))
Else
__SetTime()
EndIf
__SetDate()
While True
Sleep(3 * 60 * 60 * 1000) ; Sleep for 3 hours
MsgBox (0, "Total hours", _Format(_Diff()), 60)
WEnd
Func _AlreadyRunToday()
If IniRead($ini, "Section", "D", "") <> @MDay _
Or IniRead($ini, "Section", "M", "") <> @Mon _
Or IniRead($ini, "Section", "Y", "") <> @Year Then Return False
Return True
EndFunc
Func _ReadDate() ;Returns the time when the program run the first time in YYYY/MM/DD HH:MM:SS
Return IniRead($ini, "Section", "Y", "") & "/" & IniRead($ini, "Section", "M", "") & "/" & IniRead($ini, "Section", "D", "") & " " & IniRead($ini, "Section", "H", "") & ":" & IniRead($ini, "Section", "Mi", "") & ":" & IniRead($ini, "Section", "S", "")
EndFunc
Func __SetDate() ;Sets the date the program run the last time
IniWrite($ini, "Section", "D", @MDay)
IniWrite($ini, "Section", "M", @Mon)
IniWrite($ini, "Section", "Y", @Year)
EndFunc
Func __SetTime() ;Sets the time of the first instance running that day
IniWrite($ini, "Section", "H", @Hour)
IniWrite($ini, "Section", "Mi", @Min)
IniWrite($ini, "Section", "S", @Sec)
EndFunc
Func _Diff() ;Calculates the seconds passed since the first run today
Return _DateDiff("s", _ReadDate(), _NowCalc())
EndFunc
Func _Format($Seconds)
Local $h, $m, $s
_TicksToTime($Seconds * 1000, $h, $m, $s)
;Return $h & ":" & $m & ":" & $s
Return StringFormat("%02d:%02d:%02d", $h, $m, $s)
EndFunc