回复 8# xms77
倒计时显示
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 446, 217, 192, 124)
$Input1 = GUICtrlCreateInput("", 136, 40, 153, 21)
$Label1 = GUICtrlCreateLabel("开始运行时间倒数", 24, 40, 108, 17)
$Button1 = GUICtrlCreateButton("运行", 120, 88, 105, 41)
GUISetState(@SW_SHOW)
Global $Sec, $Min, $Hour, $Time,$iTicks ;定义变量
$StartTicks = _TimeToTicks(@HOUR, @MIN, @SEC) ;将当前时间转化为毫秒数
$EndTicks = $StartTicks + 5 * 60 * 1000 ;增加5分钟的毫秒数
#EndRegion ### END Koda GUI section ###
While 1
_jishi()
If $iTicks = 0 Then MsgBox(0, "错误", "时间到了") ;为0 说明时间到了,执行操作
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, "错误", "时间到了")
EndSwitch
WEnd
Func _jishi() ;倒计时显示,虽然用SLEEP也可以,但是我觉得这样好像准点
$nowTicks = _TimeToTicks(@HOUR, @MIN, @SEC) ;将当前时间转化为毫秒数
$iTicks = $EndTicks - $nowTicks ;算差的毫秒数
_TicksToTime($iTicks, $Hour, $Min, $Sec) ;转为时分秒
$Time = StringFormat("%02i:%02i:%02i", $Hour, $Min, $Sec) ;格式
GUICtrlSetData($Input1, $Time) ;显示
EndFunc ;==>_jishi
|