找回密码
 加入
搜索
查看: 6850|回复: 13

[AU3基础] [已解决]如何使鼠标拖动窗体倒计时不停止?

  [复制链接]
发表于 2014-12-8 23:53:28 | 显示全部楼层 |阅读模式
本帖最后由 laomeng 于 2014-12-9 21:46 编辑

在论坛上看到大侠写的倒计时,但是鼠标点到窗体上方或者移动窗体的时候 倒计时会停止,如何实现不让它停止呢?谢谢 指教!!!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
Global $time = 30
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibEnable("_timer", 1000)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit
                Case $Button1
                        ExitLoop
        EndSwitch
        If $time <= 0 Then ExitLoop
WEnd
main()
Exit
 
Func _timer()
        $time -= 1
        GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
        GUICtrlSetData($Progress1, (30 - $time) / 0.3)
        If $time <= 0 Then AdlibDisable()
EndFunc   ;==>_timer
 
Func main()
        MsgBox(0, 'test', '倒计时结束,进入主程序.', 10)
        ;以下为主程序
EndFunc   ;==>main
发表于 2014-12-9 08:51:45 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $time = 30
#Region ### START Koda GUI section ### Form=
AdlibRegister("time")
$time1 = TimerInit()
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        AdlibUnRegister("time")
                        Exit
                Case $Button1
                        ExitLoop
        EndSwitch
        If $time = 1 Then ExitLoop
WEnd
main()
Exit

Func time()
            If TimerDiff($time1) > 1000 Then
                GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
                GUICtrlSetData($Progress1, (30 - $time) / 0.3)
                $time = $time - 1
                $time1 = TimerInit()
                EndIf
EndFunc   ;==>time

Func main()
        MsgBox(0, 'test', '倒计时结束,进入主程序.', 10)
        ;以下为主程序
EndFunc   ;==>main
 楼主| 发表于 2014-12-9 10:14:12 | 显示全部楼层
回复 2# austere


    谢谢  但是 还是一样  会停止
发表于 2014-12-9 10:16:44 | 显示全部楼层
回复 3# laomeng


    你的意思是窗口没有激活,就暂停进度条吗?
发表于 2014-12-9 10:26:18 | 显示全部楼层
学习了,感谢分享!!
 楼主| 发表于 2014-12-9 10:28:30 | 显示全部楼层
回复 4# austere


    不是。
是在倒计时开始后  用鼠标点到窗体上方拖动的时候  读秒会停止,有什么办法 使它 不停止呢
发表于 2014-12-9 10:37:51 | 显示全部楼层
回复 3# laomeng


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $time = 30, $time1, $Label1, $Progress1
GUIa()
While 1
        Sleep(1000)
WEnd
Func GUIa()
        ;AdlibRegister("time")
        $time1 = TimerInit()
        $Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
        GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
        $Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
        GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
        $Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
        $Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
        GUICtrlSetOnEvent($Button1, "time")
        $Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
        GUICtrlSetOnEvent($Button2, "Form1Close")
        GUISetState(@SW_SHOW)
EndFunc   ;==>GUIaProg
Func time()
        AdlibRegister("time")
        If TimerDiff($time1) > 1000 Then
                GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
                GUICtrlSetData($Progress1, (30 - $time) / 0.3)
                $time = $time - 1
                $time1 = TimerInit()
        EndIf
        If $time = 0 Then
                main()
        EndIf       
EndFunc   ;==>time
Func main()
        MsgBox(0, 'test', '倒计时结束,进入主程序.', 1)
        ;以下为主程序
        Form1Close()
EndFunc   ;==>main
Func Form1Close()       
        Exit
EndFunc   ;==>Form1Close
 楼主| 发表于 2014-12-9 11:01:09 | 显示全部楼层
回复 7# chzj589


    谢谢你的解答,但还是没有解决我的问题

鼠标 拖动窗体  读秒还是会停止。 我记得之前有看到过 实现的方法, 现在找不到了
发表于 2014-12-9 11:24:42 | 显示全部楼层
明白你的意思了,你按了标题栏程序会暂停的~  所以用winmove来实现就可以了~
 楼主| 发表于 2014-12-9 11:36:52 | 显示全部楼层
回复 9# austere


    请指教 谢!
发表于 2014-12-9 12:24:52 | 显示全部楼层
用定时器
#Include <Timers.au3>
_Timer_SetTimer($hWnd [, $iElapse = 250 [, $sTimerFunc = "" [, $iTimerID = -1]]])
发表于 2014-12-9 15:59:23 | 显示全部楼层
Afan的办法不错,试过可行~
 楼主| 发表于 2014-12-9 21:45:21 | 显示全部楼层
回复 11# afan


    多谢提醒  已解决
 楼主| 发表于 2014-12-9 21:45:45 | 显示全部楼层
回复 12# austere


    已OK
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 23:45 , Processed in 0.086968 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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