找回密码
 加入
搜索
查看: 1522|回复: 3

[AU3基础] 几个倒计时互不干扰怎么写?

[复制链接]
发表于 2014-3-24 10:38:33 | 显示全部楼层 |阅读模式


如图:有几个倒计时,我设置好时间后,点击倒计时一中开始倒计时,诺干分钟后,我在设置倒计时二中时间进行倒计时,哪个倒计时完就弹出框框,几个倒计时互不干扰,怎么写啊!求救!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-3-24 11:38:43 | 显示全部楼层
弄两个变量
AdlibRegister
发表于 2014-3-24 12:26:41 | 显示全部楼层
adlibregister在跳出msg窗口时会停止,建议用timer
#include <winapiex.au3>

Global $itimer1=1, $itimer2 = 2
Global $time1= 60, $time2 = 60
Global $hTimerProc1 = DllCallbackRegister('_TimerProc1', 'none', 'hwnd;uint;uint_ptr;dword')
Global $hTimerProc2 = DllCallbackRegister('_TimerProc2', 'none', 'hwnd;uint;uint_ptr;dword')

AutoItSetOption("GUIOnEventMode", 1)

GUICreate("倒计时例子", 420, 140)
GUISetOnEvent(-3, "quit")
GUICtrlCreateGroup("倒计时一",10,10, 180, 120)
$htLabel1 = GUICtrlCreateLabel("00:60",20,40)
GUICtrlCreateButton("开始计时",20, 80)
GUICtrlSetOnEvent(-1, "time1")
GUICtrlCreateButton("停止计时",120, 80)
GUICtrlSetOnEvent(-1, "stop1")
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("倒计时二",230,10, 180, 120)
$htLabel2 = GUICtrlCreateLabel("00:60",240,40)
GUICtrlCreateButton("开始计时",240, 80)
GUICtrlSetOnEvent(-1, "time2")
GUICtrlCreateButton("停止计时",340, 80)
GUICtrlSetOnEvent(-1, "stop2")
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState()

While 1
        Sleep(10)
WEnd

Func quit()
        stop1()
        stop2()
        DllCallbackFree($hTimerProc1)
        DllCallbackFree($hTimerProc2)
        Exit
EndFunc

Func time1()
        $itimer1 = _WinAPI_SetTimer (0, $itimer1, 1000, DllCallBackGetPtr($hTimerProc1) )
EndFunc
Func time2()
        $itimer2 = _WinAPI_SetTimer (0, $itimer2, 1000, DllCallBackGetPtr($hTimerProc2) )
EndFunc

Func stop1()
        _WinAPI_KillTimer(0, $itimer1)
EndFunc
Func stop2()
        _WinAPI_KillTimer(0, $itimer2)
EndFunc

Func _TimerProc1($hWnd, $iMsg, $iTimerId, $iTime)
    $time1 -= 1
    If $time1 = 0 Then 
                _WinAPI_KillTimer(0, $itimer1)
                GUICtrlSetData($htLabel1, secondfunc($time1))
                MsgBox(0,"","计时一停止!")
        Else
                GUICtrlSetData($htLabel1, secondfunc($time1))
        EndIf
EndFunc

Func _TimerProc2($hWnd, $iMsg, $iTimerId, $iTime)
    $time2 -= 1
    If $time2 = 0 Then 
                _WinAPI_KillTimer(0, $itimer2)
                GUICtrlSetData($htLabel2, secondfunc($time2))
                MsgBox(0,"","计时二停止!")
        Else
                GUICtrlSetData($htLabel2, secondfunc($time2))
        EndIf
EndFunc

Func secondfunc($second)
        Return(StringFormat("%02d:%02d", Int($second/60), Mod($second, 60)))
EndFunc

评分

参与人数 1金钱 +30 收起 理由
haijie1223 + 30

查看全部评分

 楼主| 发表于 2014-3-24 13:18:45 | 显示全部楼层
谢谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-3 06:33 , Processed in 0.154640 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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