找回密码
 加入
搜索
查看: 1290|回复: 1

如何实现秒表的功能

[复制链接]
发表于 2009-1-4 08:35:44 | 显示全部楼层 |阅读模式
如何实现类似秒表的功能,按开始键开始自身加1,按停止键停止按开始键继续运行,归根结底就是想退出死循环,这个功能很有用,请大家帮帮忙
发表于 2009-1-4 09:39:08 | 显示全部楼层
楼主是要这样的功能?
[au3]#include <GUIConstants.au3>
Opt("GuiOnEventMode", 1)
$time = 5
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 449, 193, 125)
$Button1 = GUICtrlCreateButton("开始", 224, 224, 75, 25, 0)
GUICtrlSetOnEvent(-1, "ca")
$Label2 = GUICtrlCreateLabel($time, 192, 88, 36, 17)
GUISetState(@SW_SHOW)
;~ AdlibEnable("lefttime", 1000)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd

Func lefttime()
        GUICtrlSetData($Button1, "取消")
        If $time = 0 Then
                MsgBox(0, 0, "时间到")
                AdlibDisable()
                GUICtrlSetData($Button1, "开始")
        Else
                $time -= 1
                GUICtrlSetData($Label2, $time)
        EndIf
EndFunc   ;==>lefttime

Func ca()
        If GUICtrlRead($Button1) = "开始"  Then
                AdlibEnable("lefttime", 1000)
        Else
                AdlibDisable()
                MsgBox(0, 0, "已取消")
                $time = 100
                GUICtrlSetData($Button1, "开始")
                GUICtrlSetData($Label2, $time)
        EndIf
EndFunc   ;==>ca

Func quit()
        Exit
EndFunc   ;==>quit[/au3]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 09:36 , Processed in 0.070958 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表