仙乃日 发表于 2010-8-29 09:32:50

如何避免出现多个窗口?[已解决]

本帖最后由 仙乃日 于 2010-8-29 09:49 编辑

#include <GuiConstants.au3>
Global $Form1, $Label1, $Label2, $Label3, $Button1, $Button2, $Button3, $Button4, $Input1, $Input2, $Radio1, $sRadio1, $Radio2, $sRadio2, $Checkbox1, $sCheckbox1, $Checkbox2, $sCheckbox2, $Checkbox3, $sCheckbox3,$x
Opt("GUIOnEventMode", 1)
$x=1
Step_gui($x)
While 1
        Sleep(20)
        WEnd
Func Step_gui($x)
        Select
                Case $x = 1
                        $Form1 = GUICreate("离线驱动注入工具By 仙乃日", 450, 220, -1, -1)
                        $Button1 = GUICtrlCreateButton("< 上一步[&B]", 200, 185, 89, 25, 0)
                        GUICtrlSetState($Button1, $gui_disable)
                        $Button2 = GUICtrlCreateButton("下一步[&N] >", 325, 185, 89, 25, 0)
                        $Label1 = GUICtrlCreateLabel("请选择所要进行的操作!", 25, 16, 400, 30);在GUI上创建一个静态标签(Label)控件 GUICtrlCreateLabel ( "文本", 左侧, 顶部 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]]
                        GUICtrlSetFont($Label1, 12, 650, 2)
                        $Radio1 = GUICtrlCreateRadio("清除目标系统中所有的大容量存储控制器驱动!", 35, 45, 400, 20)
                        $Radio2 = GUICtrlCreateRadio("清除目标系统中的大容量存储控制器驱动,但保留适合本机的驱动!", 35, 70)
                        $Checkbox1 = GUICtrlCreateCheckbox("从PE中注入适合本机的大容量存储控制器驱动!", 35, 95)
                        $Checkbox2 = GUICtrlCreateCheckbox("注入适合本机的第3方厂商大容量存储控制器驱动!", 35, 120)
                        GUICtrlSetState($Checkbox2, $gui_disable)
                        $Checkbox3 = GUICtrlCreateCheckbox("自动更改目标系统的电源模式,使其适合本机!", 35, 145)
                        GUICtrlSetState($Checkbox3, $gui_disable)
                        GUISetState()
                       
                        GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button1,"GUI_CTRL")
                        GUICtrlSetOnEvent($Button2,"GUI_CTRL")
                Case $x = 2
                        GUICtrlSetState($Button1, $gui_enable)
                        If GUICtrlRead($Radio1) = $GUI_CHECKED Then $sRadio1 = 1
                        GUICtrlSetState($Radio1, $gui_hide)
                        If GUICtrlRead($Radio2) = $GUI_CHECKED Then $sRadio2 = 1
                        GUICtrlSetState($Radio2, $gui_hide)
                        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sCheckbox1 = 1
                        GUICtrlSetState($Checkbox1, $gui_hide)
                        If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $sCheckbox2 = 1
                        GUICtrlSetState($Checkbox2, $gui_hide)
                        If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $sCheckbox3 = 1
                        GUICtrlSetState($Checkbox3, $gui_hide)
                        GUICtrlSetState($Button2, $gui_disable)

                        GUICtrlSetData($Label1, "请选择目标系统所在的目录和第3方厂商驱动所在的目录!")
                        GUICtrlSetFont($Label1, 11, 580, 0)
                        $Label2 = GUICtrlCreateLabel("系统路径:", 25, 68, 80, 25)
                        GUICtrlSetFont($Label2, 12, 550, 0)
                        $Button3 = GUICtrlCreateButton("打开", 310, 65, 45, 25)
                        $Input1 = GUICtrlCreateInput("", 105, 65, 200, 25)
                        $Label3 = GUICtrlCreateLabel("驱动路径:", 25, 113, 80, 25)
                        GUICtrlSetFont($Label3, 12, 550, 0)
                        $Input2 = GUICtrlCreateInput("", 105, 110, 200, 25)
                        $Button4 = GUICtrlCreateButton("打开", 310, 110, 45, 25)
        EndSelect
EndFunc   ;==>Step_gui


Func GUI_CTRL()
       
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $x -=1
                        Step_gui($x)
                Case $Button2
                                If GUICtrlRead($Button2) = "完成[&F]" Then Exit
                                $x +=1
                                Step_gui($x)
                               
        EndSwitch

EndFunc   ;==>_GUI_CTRL
自己初学GUI很多基本的知识都不懂。这个界面在多次按“上一步”“下一步”后就会出现多个窗口,如何避免呢?

仙乃日 发表于 2010-8-29 09:49:25

谢谢 水木子 帮忙!#include <GuiConstants.au3>
Global $Form1, $Label1, $Label2, $Label3, $Button1, $Button2, $Button3, $Button4, $Input1, $Input2, $Radio1, $sRadio1, $Radio2, $sRadio2, $Checkbox1, $sCheckbox1, $Checkbox2, $sCheckbox2, $Checkbox3, $sCheckbox3, $x
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("离线驱动注入工具By 仙乃日", 450, 220, -1, -1)
$Button1 = GUICtrlCreateButton("< 上一步[&B]", 200, 185, 89, 25, 0)
GUICtrlSetState($Button1, $gui_disable)
$Button2 = GUICtrlCreateButton("下一步[&N] >", 325, 185, 89, 25, 0)
$x = 1
Step_gui($x)
While 1
        Sleep(20)
WEnd
Func Step_gui($x)
        Select
                Case $x = 1

                        $Label1 = GUICtrlCreateLabel("请选择所要进行的操作!", 25, 16, 400, 30);在GUI上创建一个静态标签(Label)控件 GUICtrlCreateLabel ( "文本", 左侧, 顶部 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]]
                        GUICtrlSetFont($Label1, 12, 650, 2)
                        $Radio1 = GUICtrlCreateRadio("清除目标系统中所有的大容量存储控制器驱动!", 35, 45, 400, 20)
                        $Radio2 = GUICtrlCreateRadio("清除目标系统中的大容量存储控制器驱动,但保留适合本机的驱动!", 35, 70)
                        $Checkbox1 = GUICtrlCreateCheckbox("从PE中注入适合本机的大容量存储控制器驱动!", 35, 95)
                        $Checkbox2 = GUICtrlCreateCheckbox("注入适合本机的第3方厂商大容量存储控制器驱动!", 35, 120)
                        GUICtrlSetState($Checkbox2, $gui_disable)
                        $Checkbox3 = GUICtrlCreateCheckbox("自动更改目标系统的电源模式,使其适合本机!", 35, 145)
                        GUICtrlSetState($Checkbox3, $gui_disable)
                        GUISetState()

                        GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button1, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button2, "GUI_CTRL")
                        ;控件切换
                        GUICtrlSetState($Button1, $gui_disable)
                        GUICtrlSetState($Button2, $gui_enable)
                        GUICtrlSetState($Label2, $gui_hide)
                        GUICtrlSetState($Button3, $gui_hide)
                        GUICtrlSetState($Input1, $gui_hide)
                        GUICtrlSetState($Label3, $gui_hide)
                        GUICtrlSetState($Input2, $gui_hide)
                        GUICtrlSetState($Button4, $gui_hide)
                Case $x = 2
                        GUICtrlSetState($Button1, $gui_enable)
                        If GUICtrlRead($Radio1) = $GUI_CHECKED Then $sRadio1 = 1
                        GUICtrlSetState($Radio1, $gui_hide)
                        If GUICtrlRead($Radio2) = $GUI_CHECKED Then $sRadio2 = 1
                        GUICtrlSetState($Radio2, $gui_hide)
                        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sCheckbox1 = 1
                        GUICtrlSetState($Checkbox1, $gui_hide)
                        If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $sCheckbox2 = 1
                        GUICtrlSetState($Checkbox2, $gui_hide)
                        If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $sCheckbox3 = 1
                        GUICtrlSetState($Checkbox3, $gui_hide)
                        GUICtrlSetState($Button2, $gui_disable)

                        GUICtrlSetData($Label1, "请选择目标系统所在的目录和第3方厂商驱动所在的目录!")
                        GUICtrlSetFont($Label1, 11, 580, 0)
                        $Label2 = GUICtrlCreateLabel("系统路径:", 25, 68, 80, 25)
                        GUICtrlSetFont($Label2, 12, 550, 0)
                        $Button3 = GUICtrlCreateButton("打开", 310, 65, 45, 25)
                        $Input1 = GUICtrlCreateInput("", 105, 65, 200, 25)
                        $Label3 = GUICtrlCreateLabel("驱动路径:", 25, 113, 80, 25)
                        GUICtrlSetFont($Label3, 12, 550, 0)
                        $Input2 = GUICtrlCreateInput("", 105, 110, 200, 25)
                        $Button4 = GUICtrlCreateButton("打开", 310, 110, 45, 25)
        EndSelect
EndFunc   ;==>Step_gui


Func GUI_CTRL()

        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $x -= 1
                        Step_gui($x)
                Case $Button2
                        If GUICtrlRead($Button2) = "完成[&F]" Then Exit
                        $x += 1
                        Step_gui($x)

        EndSwitch

EndFunc   ;==>GUI_CTRL
页: [1]
查看完整版本: 如何避免出现多个窗口?[已解决]