#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("全部选择与取消选择", 261, 251, 340, 162)
$Checkbox1 = GUICtrlCreateCheckbox("1", 50, 50, 25, 17)
$Checkbox2 = GUICtrlCreateCheckbox("2", 120, 50, 25, 17)
$Checkbox3 = GUICtrlCreateCheckbox("3", 190, 50, 25, 17)
$Checkbox4 = GUICtrlCreateCheckbox("4", 50, 100, 25, 17)
$Checkbox5 = GUICtrlCreateCheckbox("5", 120, 100, 25, 17)
$Checkbox6 = GUICtrlCreateCheckbox("6", 190, 100, 25, 17)
$Checkbox7 = GUICtrlCreateCheckbox("7", 50, 150, 25, 17)
$Checkbox8 = GUICtrlCreateCheckbox("8", 120, 150, 25, 17)
$Checkbox9 = GUICtrlCreateCheckbox("9", 190, 150, 25, 17)
$Group1 = GUICtrlCreateGroup("10", 24, 24, 209, 169)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("全部选择", 90, 210, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
Checkbox()
Case $Checkbox2
Checkbox()
Case $Checkbox3
Checkbox()
Case $Checkbox4
Checkbox()
Case $Checkbox5
Checkbox()
Case $Checkbox6
Checkbox()
Case $Checkbox7
Checkbox()
Case $Checkbox8
Checkbox()
Case $Checkbox9
Checkbox()
Case $Button1
For $i=1 To 9
If GUICtrlRead($Button1)="取消选择" Then
GUICtrlSetState (Eval("Checkbox"&$i),$GUI_UNCHECKED)
Else
GUICtrlSetState (Eval("Checkbox"&$i),$GUI_CHECKED)
EndIf
Next
If GUICtrlRead($Button1)="取消选择" Then
GUICtrlSetData($Button1,"全部选择")
Else
GUICtrlSetData($Button1,"取消选择")
EndIf
EndSwitch
WEnd
Func Checkbox()
For $i=1 To 9
If GUICtrlRead(Eval("Checkbox"&$i))=4 Then ExitLoop
Next
If $i=10 Then
GUICtrlSetData($Button1,"取消选择")
Else
GUICtrlSetData($Button1,"全部选择")
EndIf
EndFunc