本帖最后由 骗子 于 2011-12-1 15:49 编辑
用GUIOnEventMode
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <file.au3>
#include <GuiButton.au3>
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <Timers.au3>
#include <ListboxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("伪秒表", 556, 310, 198, 123)
$StartButton = GUICtrlCreateButton("开始", 328, 176, 185, 105)
GUICtrlSetFont(-1, 42, 800, 0, "微软雅黑")
$Time = GUICtrlCreateLabel("00:00:00:00", 12, 25, 520, 128)
GUICtrlSetFont(-1, 72, 400, 0, "微软雅黑")
GUICtrlSetBkColor(-1, 0xFF0000)
$ResetButton = GUICtrlCreateButton("重置", 29, 176, 185, 105)
GUICtrlSetFont(-1, 42, 800, 0, "微软雅黑")
;~ $SmallTime = GUICtrlCreateLabel("00", 418, 45, 98, 108)
;~ GUICtrlSetFont(-1, 60, 400, 0, "微软雅黑")
;~ GUICtrlSetBkColor(-1, 0xFF0000)
;~ GUICtrlCreateLabel("", 416, 25, 100, 20)
;~ GUICtrlSetFont(-1, 72, 400, 0, "微软雅黑")
;~ GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($StartButton, "_kaiguan")
GUICtrlSetOnEvent($ResetButton, "_chushuhua")
#endregion ### END Koda GUI section ###
Global $shi = 0, $fen = 0, $miao = 0, $haomiao = 0, $kaiguan = 1, $begin, $dif
While 1
Sleep(100)
_jishu()
WEnd
Func _kaiguan()
If $kaiguan = 1 Then
$kaiguan = 0
GUICtrlSetData($StartButton, "开始")
$begin = TimerInit()
Else
$kaiguan = 1
GUICtrlSetData($StartButton, "暂停")
$dif = TimerDiff($begin)
MsgBox(0, "实际用时:", $dif)
EndIf
EndFunc ;==>_kaiguan
Func _jishu()
If $kaiguan = 0 Then
$Time1 = StringFormat("%02i:%02i:%02i:%2i", $shi, $fen, $miao, $haomiao)
GUICtrlSetData($Time, $Time1)
$haomiao += 1
If $haomiao > 9 Then
$miao += 1
$haomiao = 0
EndIf
If $miao > 59 Then
$miao = 0
$fen += 1
EndIf
If $fen > 59 Then
$fen = 0
$shi += 1
EndIf
EndIf
EndFunc ;==>_jishu
Func _chushuhua()
Global $shi = 0, $fen = 0, $miao = 0, $haomiao = 0
$Time1 = StringFormat("%02i:%02i:%02i:%02i", $shi, $fen, $miao, $haomiao)
GUICtrlSetData($Time, $Time1)
EndFunc ;==>_chushuhua
|