[已解决]請問有辦法讓多個checkbox只能單選嗎?
本帖最后由 ipmitool 于 2016-12-28 12:12 编辑請問有辦法讓多個checkbox只能單選嗎?#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = Guicreate("OS Install", 230, 400, -1, -1)
$Button1 = GuiCtrlCreateButton("Install", 120, 280, 50, 50)
$Group1 = GUICtrlCreateGroup("OS Version", 10, 70, 200, 120)
$Group2 = GUICtrlCreateGroup("Disk Select", 10, 210, 200, 170)
$Radio1 = GUICtrlCreateRadio("RHEL7.1", 30, 100, 80, 20)
$Radio2 = GUICtrlCreateRadio("RHEL7.2", 30, 130, 80, 20)
$Radio3 = GUICtrlCreateRadio("XXX", 30, 160, 80, 20)
$Checkbox1 = GUICtrlCreateCheckbox("sda", 40, 230, 60, 20)
$Checkbox2 = GUICtrlCreateCheckbox("sdb", 40, 260, 60, 20)
$Checkbox3 = GUICtrlCreateCheckbox("sdc", 40, 290, 60, 20)
$Checkbox4 = GUICtrlCreateCheckbox("sdd", 40, 320, 60, 20)
$Checkbox5 = GUICtrlCreateCheckbox("sde", 40, 350, 60, 20)
$testconfig =FileOpen("testconfig.ini",1)
GuiSetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,"Execute Test Case","OSInstallation",0.5)
FileWriteLine($testconfig, "")
if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
;GUICtrlSetState($Checkbox2, 1)
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sda")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdb")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdc")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdd")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdb")
EndIf
EndIf
if BitAnd(GUICtrlRead($Radio2),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\Windows R2 files\r2.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\amd driver\chipset.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\ATI\vga.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\BCM5723FW\nic.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
RunWait("shutdown -r -f -t 0","")
EndIf
EndIf
if BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\Windows R2 files\r2.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\infinst_autol\chipset.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\ATI\vga.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\LAN\Release_15.3_OEM_Gene_PV_216072\nic.exe","")
RunWait(@DesktopDir&"\LAN\LwsvillWW28ER_220106\nic.exe","")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
RunWait("shutdown -r -f -t 0","")
EndIf
EndIf
FileWriteLine($testconfig, "")
sleep(1000)
winclose("OS Install")
EndSwitch
Wend
回复 1# ipmitool
沒這麼複雜吧 勾選$Checkbox4 後 會觸發$Checkbox4
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox4
判斷 是否 勾選是的話就把其他的 都設為未勾選
不是勾選的 畫 就設為勾選
..
..
..
這樣不就好了 本帖最后由 1361739590 于 2016-12-28 10:37 编辑
單選为什么用checkbox呢
GUICtrlCreateGroup组合起来就好了。 本帖最后由 q410225 于 2016-12-28 11:05 编辑
为什么不使用Radio呢,
当然用复选框也可以,创建的时候使用样式$BS_AUTORADIOBUTTON就可以了
$Radio3 = GUICtrlCreateRadio("XXX", 30, 160, 80, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Checkbox1 = GUICtrlCreateCheckbox("sda", 40, 230, 60, 20,$BS_AUTORADIOBUTTON)
或者你可以在消息循环的时候进行判断,
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 then
GUICtrlSetState($Checkbox2,$GUI_UNCHECKED) 假設我都用ratio的話, RHEL6.5跟sda就寫不進去testconfig.ini檔...是不是我語法錯誤拉...
if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sda")
EndIf#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
$Form1 = Guicreate("OS Install", 420, 150, -1, -1)
$Group1 = GUICtrlCreateGroup("OS Version", 10, 10, 120, 120)
$Group2 = GUICtrlCreateGroup("Disk Select", 140, 10, 200, 120)
$Radio1 = GUICtrlCreateRadio("RHEL6.5", 20, 30, 80, 20)
$Radio2 = GUICtrlCreateRadio("RHEL7.1", 20, 55, 80, 20)
$Radio3 = GUICtrlCreateRadio("RHEL7.2", 20, 80, 80, 20)
$Checkbox1 = GUICtrlCreateCheckbox("sda", 155, 30, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox2 = GUICtrlCreateCheckbox("sdb", 155, 55, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox3 = GUICtrlCreateCheckbox("sdc", 155, 80, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox4 = GUICtrlCreateCheckbox("sdd", 155, 105, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox5 = GUICtrlCreateCheckbox("sde", 215, 30, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox6 = GUICtrlCreateCheckbox("sdf", 215, 55, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox7 = GUICtrlCreateCheckbox("sdg", 215, 80, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox8 = GUICtrlCreateCheckbox("sdh", 215, 105, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox9 = GUICtrlCreateCheckbox("sdi", 275, 30, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox10 = GUICtrlCreateCheckbox("sdj", 275, 55, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox11 = GUICtrlCreateCheckbox("sdk", 275, 80, 60, 20,$BS_AUTORADIOBUTTON)
$Checkbox12 = GUICtrlCreateCheckbox("sdl", 275, 105, 60, 20,$BS_AUTORADIOBUTTON)
$Button1 = GuiCtrlCreateButton("Execute", 350, 100, 50, 30)
$testconfig =FileOpen("testconfig.ini",1) ; 1:繼續往下寫
GuiSetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,"Execute Test Case","OSInstallation",0.5)
FileWriteLine($testconfig, "")
if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
;GUICtrlSetState($Checkbox2, 1)
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sda")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdb")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdc")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdd")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sde")
EndIf
if BitAnd(GUICtrlRead($Checkbox6),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdf")
EndIf
if BitAnd(GUICtrlRead($Checkbox7),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdg")
EndIf
if BitAnd(GUICtrlRead($Checkbox8),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdh")
EndIf
if BitAnd(GUICtrlRead($Checkbox9),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdi")
EndIf
if BitAnd(GUICtrlRead($Checkbox10),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdj")
EndIf
if BitAnd(GUICtrlRead($Checkbox11),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdk")
EndIf
if BitAnd(GUICtrlRead($Checkbox12),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL6.5")
FileWriteLine($testconfig, "sdl")
EndIf
EndIf
if BitAnd(GUICtrlRead($Radio2),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
;GUICtrlSetState($Checkbox2, 1)
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sda")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdb")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdc")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdd")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sde")
EndIf
if BitAnd(GUICtrlRead($Checkbox6),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdf")
EndIf
if BitAnd(GUICtrlRead($Checkbox7),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdg")
EndIf
if BitAnd(GUICtrlRead($Checkbox8),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdh")
EndIf
if BitAnd(GUICtrlRead($Checkbox9),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdi")
EndIf
if BitAnd(GUICtrlRead($Checkbox10),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdj")
EndIf
if BitAnd(GUICtrlRead($Checkbox11),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdk")
EndIf
if BitAnd(GUICtrlRead($Checkbox12),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.1")
FileWriteLine($testconfig, "sdl")
EndIf
EndIf
if BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED)=1 Then
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)=1 Then
;GUICtrlSetState($Checkbox2, 1)
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sda")
EndIf
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdb")
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdc")
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdd")
EndIf
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sde")
EndIf
if BitAnd(GUICtrlRead($Checkbox6),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdf")
EndIf
if BitAnd(GUICtrlRead($Checkbox7),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdg")
EndIf
if BitAnd(GUICtrlRead($Checkbox8),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdh")
EndIf
if BitAnd(GUICtrlRead($Checkbox9),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdi")
EndIf
if BitAnd(GUICtrlRead($Checkbox10),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdj")
EndIf
if BitAnd(GUICtrlRead($Checkbox11),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdk")
EndIf
if BitAnd(GUICtrlRead($Checkbox12),$GUI_CHECKED)=1 Then
FileWriteLine($testconfig, "RHEL7.2")
FileWriteLine($testconfig, "sdl")
EndIf
EndIf
FileWriteLine($testconfig, "")
sleep(1000)
winclose("OS Install")
EndSwitch
Wend
sleep(2000)
回复 5# ipmitool
需要加上GUICtrlCreateGroup("", -99, -99, 1, 1),把两组radio分割开 回复 6# q410225
原來是這樣啊, 謝謝大家幫忙搞定~
页:
[1]