已解决-求教,如何达到选择一个radio,就会自动勾选相关checkbox?
本帖最后由 pzypdl2006 于 2016-3-5 14:55 编辑#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试", 625, 442, 192, 124)
$Radio1 = GUICtrlCreateRadio("模式1", 88, 56, 113, 17)
$Radio2 = GUICtrlCreateRadio("模式2", 248, 56, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("项目1", 88, 120, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("项目2", 216, 120, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("项目3", 344, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("项目4", 88, 152, 97, 17)
$Checkbox5 = GUICtrlCreateCheckbox("项目5", 216, 152, 97, 17)
$Checkbox6 = GUICtrlCreateCheckbox("项目6", 344, 152, 97, 17)
$Button1 = GUICtrlCreateButton("运行", 424, 200, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
想达到的目的:
选择【模式1】,则会自动勾选【项目1、项目2】;
选择【模式2】,则会自动勾选【项目3、项目4】;
点击运行,则会自动依次运行勾选的项目!
求帮哦! #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试", 625, 442, 192, 124)
$Radio1 = GUICtrlCreateRadio("模式1", 88, 56, 113, 17)
$Radio2 = GUICtrlCreateRadio("模式2", 248, 56, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("项目1", 88, 120, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("项目2", 216, 120, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("项目3", 344, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("项目4", 88, 152, 97, 17)
$Checkbox5 = GUICtrlCreateCheckbox("项目5", 216, 152, 97, 17)
$Checkbox6 = GUICtrlCreateCheckbox("项目6", 344, 152, 97, 17)
$Button1 = GUICtrlCreateButton("运行", 424, 200, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio1
Local $a = [$Checkbox1, $Checkbox2]
_Choose($a)
Case $Radio2
Local $a = [$Checkbox3, $Checkbox4]
_Choose($a)
Case $Button1
_Run()
EndSwitch
WEnd
Func _Run()
Local $i
For $i = $Checkbox1 To $Checkbox6
If GUICtrlRead($i) = 1 Then MsgBox(0, '运行', 'RunWait("' & GUICtrlRead($i, 1) & '")')
Next
EndFunc ;==>_Run
Func _Choose($a)
Local $i
If Not IsArray($a) Then Return
For $i = $Checkbox1 To $Checkbox6
GUICtrlSetState($i, 4)
Next
For $i = 0 To UBound($a) - 1
GUICtrlSetState($a[$i], 1)
Next
EndFunc ;==>_Choose
回复 2# afan
那如何给【checkbox1】赋值呢?
比如把1.exe赋给checkbox1
把命令Run()赋给checkbox2
?? #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$Form1 = Guicreate("Client PC 自動化安裝程式", 340, 125, -1, -1)
$Button1 = GuiCtrlCreateButton("全選", 10, 95, 60, 20)
$Button2 = GuiCtrlCreateButton("取消全選", 130, 95, 60, 20)
$Button3 = GuiCtrlCreateButton("執行", 250, 95, 60, 20)
$Checkbox1 = GUICtrlCreateCheckbox("Office2003", 10, 10, 120, 20)
$Checkbox2 = GUICtrlCreateCheckbox("還原軟件", 10, 40, 120, 20)
$Checkbox3 = GUICtrlCreateCheckbox("AdbeRdr810", 10, 70, 120, 20)
$Checkbox4 = GUICtrlCreateCheckbox("Java", 130, 10, 120, 20)
$Checkbox5 = GUICtrlCreateCheckbox("7-Zip", 130, 40, 120, 20)
$Checkbox6 = GUICtrlCreateCheckbox("ERP", 130, 70, 120, 20)
$Checkbox7 = GUICtrlCreateCheckbox("VNC監視器", 250, 10, 120, 20)
$Checkbox8 = GUICtrlCreateCheckbox("Xn View", 250, 40, 120, 20)
$Checkbox9 = GUICtrlCreateCheckbox("IE7", 250, 70, 120, 20)
GuiSetState(@SW_SHOW)
HotKeySet("{ESC}", "_Exit") ;按Esc結束程式
Func _Exit()
Exit 0
EndFunc
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1 ;設定Checkbox 1~11 全選
GUICtrlSetState($Checkbox1,$GUI_CHECKED)
GUICtrlSetState($Checkbox2,$GUI_CHECKED)
GUICtrlSetState($Checkbox3,$GUI_CHECKED)
GUICtrlSetState($Checkbox4,$GUI_CHECKED)
GUICtrlSetState($Checkbox5,$GUI_CHECKED)
GUICtrlSetState($Checkbox6,$GUI_CHECKED)
GUICtrlSetState($Checkbox7,$GUI_CHECKED)
GUICtrlSetState($Checkbox8,$GUI_CHECKED)
GUICtrlSetState($Checkbox9,$GUI_CHECKED)
Case $Button2 ;設定Checkbox 1~11 取消全選
GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox5,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox6,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox7,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox8,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox9,$GUI_UNCHECKED)
Case $Button3
If BitAND(GUICtrlRead($Checkbox1),$gui_checked) Then
RunWait("各軟體Auto\5.安裝Office2003.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox2),$gui_checked) Then
RunWait("各軟體Auto\2.安裝還原軟件.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox3),$gui_checked) Then
RunWait("各軟體Auto\3.安裝AdbeRdr810.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox4),$gui_checked) Then
RunWait("各軟體Auto\4.安裝Java.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox5),$gui_checked) Then
RunWait("各軟體Auto\1.安裝7-Zip.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox6),$gui_checked) Then
RunWait("各軟體Auto\6.安裝ERP.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox7),$gui_checked) Then
RunWait("各軟體Auto\7.安裝VNC監視器.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox8),$gui_checked) Then
RunWait("各軟體Auto\8.安裝Xn View.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox9),$gui_checked) Then
RunWait("各軟體Auto\9.安裝IE7.exe",@ScriptDir)
EndIf
MsgBox(0,"Auto Install Script","Auto Client Install 自動安裝、設定完畢" &@LF& " 請立即重新開機完成安裝程序")
EndSwitch
Wend 回复 4# txen548
难道不能赋值一个exe文件给checkbox吗?
页:
[1]