shangpan 发表于 2009-1-12 12:08:48

选择单选框后让进度条暂停

准备做一个OEM切换工具,想默认10秒后退出,可是选择其中的单选框了,进度条还在走,10秒后还是会自动退出。
怎么能让选择其中一个单选框后就让进度条暂停或者停止。

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OEM切换工具", 300, 235, 205, 136)
$Group1 = GUICtrlCreateGroup("", 3, -2, 293, 233)
$Label1 = GUICtrlCreateLabel("OEM切换工具", 91, 14, 110, 23)
GUICtrlSetFont(-1, 14, 400, 0, "黑体")
$Radio1 = GUICtrlCreateRadio("联想 ", 11, 54, 129, 17)
$Radio2 = GUICtrlCreateRadio("方正 ", 11, 78, 129, 17)
$Radio3 = GUICtrlCreateRadio("清华同方 ", 11, 102, 129, 17)
$Radio4 = GUICtrlCreateRadio("惠普 ", 11, 126, 129, 17)
$Radio5 = GUICtrlCreateRadio("戴尔 ", 11, 150, 129, 17)
$Radio6 = GUICtrlCreateRadio("IBM ", 11, 174, 129, 17)
$Progress1 = GUICtrlCreateProgress(19, 198, 257, 25)
GUICtrlSetColor(-1, 0x7A96DF)
$Button1 = GUICtrlCreateButton("安 装 (&Y)", 171, 94, 81, 25, 0)
$Button2 = GUICtrlCreateButton("退 出 (&N)", 171, 126, 81, 25, 0)
$Label2 = GUICtrlCreateLabel("10秒后自动退出", 184, 168, 88, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Label3 = GUICtrlCreateLabel("请选择相应的品牌机名称", 144, 56, 136, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Label4 = GUICtrlCreateLabel("其它品牌和组装机请退出", 144, 72, 136, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


;GUICtrlSetState($Radio1, $GUI_CHECKED)
HotKeySet("{y}", "Button1Click")
HotKeySet("{Y}", "Button1Click")
HotKeySet("{n}", "Button2Click")
HotKeySet("{N}", "Button2Click")


$time = 10
AdlibEnable("pro1", 1000)
Func pro1()
    $time -= 1
    GUICtrlSetData($Label2,$time & "秒后自动退出!")
    GUICtrlSetData($Progress1, (10 - $time) / 0.1)
    If $time <= 0 Then Exit
EndFunc


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Func Button1Click()
_res()
EndFunc

Func Button2Click()
exit
EndFunc

顽固不化 发表于 2009-1-12 14:11:15

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OEM切换工具", 300, 235, 205, 136)
$Group1 = GUICtrlCreateGroup("", 3, -2, 293, 233)
$Label1 = GUICtrlCreateLabel("OEM切换工具", 91, 14, 110, 23)
GUICtrlSetFont(-1, 14, 400, 0, "黑体")
$Radio1 = GUICtrlCreateRadio("联想 ", 11, 54, 129, 17)
$Radio2 = GUICtrlCreateRadio("方正 ", 11, 78, 129, 17)
$Radio3 = GUICtrlCreateRadio("清华同方 ", 11, 102, 129, 17)
$Radio4 = GUICtrlCreateRadio("惠普 ", 11, 126, 129, 17)
$Radio5 = GUICtrlCreateRadio("戴尔 ", 11, 150, 129, 17)
$Radio6 = GUICtrlCreateRadio("IBM ", 11, 174, 129, 17)
$Progress1 = GUICtrlCreateProgress(19, 198, 257, 25)
GUICtrlSetColor(-1, 0x7A96DF)
$Button1 = GUICtrlCreateButton("安 装 (&Y)", 171, 94, 81, 25, 0)
$Button2 = GUICtrlCreateButton("退 出 (&N)", 171, 126, 81, 25, 0)
$Label2 = GUICtrlCreateLabel("10秒后自动退出", 184, 168, 88, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Label3 = GUICtrlCreateLabel("请选择相应的品牌机名称", 144, 56, 136, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Label4 = GUICtrlCreateLabel("其它品牌和组装机请退出", 144, 72, 136, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


;GUICtrlSetState($Radio1, $GUI_CHECKED)
HotKeySet("{y}", "Button1Click")
HotKeySet("{Y}", "Button1Click")
HotKeySet("{n}", "Button2Click")
HotKeySet("{N}", "Button2Click")

Global $Stop = False
$time = 10
AdlibEnable("pro1", 1000)
Func pro1()
        If $Stop = False Then
                $time -= 1
                GUICtrlSetData($Label2, $time & "秒后自动退出!")
                GUICtrlSetData($Progress1, (10 - $time) / 0.1)
                If $time <= 0 Then Exit
        EndIf
EndFunc   ;==>pro1


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Radio1
                        $Stop = True
                Case $Radio2
                        $Stop = True
                Case $Radio3
                        $Stop = True
                Case $Radio4
                        $Stop = True
                Case $Radio5
                        $Stop = True
                Case $Radio6
                        $Stop = True
        EndSwitch
WEnd

Func Button1Click()
        _res()
EndFunc   ;==>Button1Click

Func Button2Click()
        Exit
EndFunc   ;==>Button2Click

Func _res()
EndFunc   ;==>_res
页: [1]
查看完整版本: 选择单选框后让进度条暂停