找回密码
 加入
搜索
查看: 3895|回复: 7

[网络通信] 【已经解决】请问 如何做出那种倒计时后自动关闭的提示窗

  [复制链接]
发表于 2012-8-18 20:31:34 | 显示全部楼层 |阅读模式
本帖最后由 yunnl 于 2012-8-18 21:13 编辑


Button按钮会更新倒计时时间
然后时间到了 或者点击按钮都会退出窗口
小弟不才 摸不透。。。
求前辈们指导指导
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(3秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $i = 3
While $i <> 0
        $i = $i - 1
        Sleep(1000)
        GUICtrlSetData($Button1, "倒计时("&$i&"秒)")
WEnd

本帖子中包含更多资源

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

×
发表于 2012-8-18 20:52:43 | 显示全部楼层
本帖最后由 南一 于 2012-8-18 20:55 编辑

使用API定时器来控制


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $s = 5
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(" & $s & "秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
$Timer = DllCallbackRegister("_daojishi", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button1
                        DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL[0])
                        Exit

        EndSwitch
WEnd

Func _daojishi($hWnd, $uiMsg, $Form1_idEvent, $dwTime)
        If $s < 1 Then
                GUICtrlSetData($Button1, "退出")
                Exit
        EndIf
        $s -= 1
        GUICtrlSetData($Button1, "倒计时(" & $s & "秒)")
EndFunc   ;==>_daojishi





发表于 2012-8-18 21:10:17 | 显示全部楼层
本帖最后由 半芯竹 于 2012-8-18 21:29 编辑

Global $time = 5
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(5秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
AdlibRegister("_timer", 1000)
While 1
        Switch GUIGetMsg()
                Case - 3,$Button1
                                                Exit
        EndSwitch
WEnd
Func _timer()
        $time -= 1
       GUICtrlSetData($Button1, "倒计时("&$time&")秒" )
        If $time <= 0 Then Exit
EndFunc   ;==>_timer
 楼主| 发表于 2012-8-18 21:11:28 | 显示全部楼层
回复 2# 南一


    谢谢~ 我慢慢研究下~
 楼主| 发表于 2012-8-18 21:12:17 | 显示全部楼层
回复 3# 半芯竹


    非常感谢~ 学习了~
发表于 2012-8-18 21:24:05 | 显示全部楼层
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(5秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
Global $timeA=5
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
While 1
        Switch GUIGetMsg()
                Case - 3,$Button1
                                                Exit
        EndSwitch
WEnd
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
        If $idEvent = $TimerDLL[0] Then
                        $timeA-=1
                GUICtrlSetData($Button1, "倒计时("&$timeA&"秒)"  )
                                If $timeA=0 Then Exit
        EndIf
EndFunc
发表于 2012-8-20 00:06:13 | 显示全部楼层
udf区,afan写过一个倒计时msgbox的函数
发表于 2012-8-20 08:40:09 | 显示全部楼层
不错.顶一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-13 01:17 , Processed in 0.092893 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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