faustf Posted April 14, 2016 Share Posted April 14, 2016 hi guy i have many checkbox , 1 to 35 , i must set it checked or not , (before i read in txt if is checked or not ), is possible if $checkbox have generic name $chekbox1, or 2 or 3 ... 35 , create someting like Local $flag80 = GUICtrlRead($Checkbox&$b) and put inside a DO cicle for increase $b UNTIL 35 ?? Link to comment Share on other sites More sharing options...
AutoBert Posted April 14, 2016 Share Posted April 14, 2016 (edited) Better is to store the ControlIDs in a Array. When using a 2D Array you can also store the func name to be called when Button is clicked: expandcollapse popup#include <GUIConstantsEx.au3> ;#include <Array.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global $aBtnIds[9][2] $aBtnIds[0][1] = "func1" $aBtnIds[1][1] = "func2" $aBtnIds[2][1] = "func3" $aBtnIds[3][1] = "func4" $aBtnIds[4][1] = "func5" $aBtnIds[5][1] = "func6" $aBtnIds[6][1] = "func7" $aBtnIds[7][1] = "func8" $aBtnIds[8][1] = "func9" Global $iSeg Global $hGui = GUICreate('CheckBoxtest', 105, 175) Global $msg For $i = 0 To 8 $aBtnIds[$i][0] = GUICtrlCreateCheckBox($i + 1, 10 + Mod($i, 3) * 30, 10 + Int($i / 3) * 30, 25, 25) GUICtrlSetOnEvent(-1, '_Click') ConsoleWrite($i + 1 & ': ' & $aBtnIds[$i][0] & @CRLF) Next Global $idBtnSubmit = GUICtrlCreateButton('OK', 10, 110, 90, 25) ConsoleWrite('OK: ' & $idBtnSubmit & @CRLF) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetOnEvent(-1, '_Submit') Global $idProgress=GUICtrlCreateProgress(10,140,85,25) GUISetOnEvent($GUI_EVENT_CLOSE,'_Exit') GUISetState() While 1 Sleep(10000) WEnd Func _Click() ;ConsoleWrite(@GUI_CtrlId&@CRLF) Local $bAtLeastOneCheckBoxChecked For $i = 0 To 8 If BitAND(GUICtrlRead($aBtnIds[$i][0]),$GUI_checked)=$GUI_checked Then $bAtLeastOneCheckBoxChecked = True ExitLoop EndIf Next If $bAtLeastOneCheckBoxChecked Then GUICtrlSetState($idBtnSubmit, $GUI_ENABLE) Else GUICtrlSetState($idBtnSubmit, $GUI_DISABLE) EndIf EndFunc ;==>_Click Func _Submit() Local $sFunc='', $iCount GUICtrlSetData($idProgress,0) For $i = 0 To 8 If BitAND(GUICtrlRead($aBtnIds[$i][0]),$GUI_checked)=$GUI_checked Then $iCount+=1 Next $iSeg=Int(100/$iCount) For $i = 0 To 8 If BitAND(GUICtrlRead($aBtnIds[$i][0]),$GUI_checked)=$GUI_checked Then Call($aBtnIds[$i][1]) $sFunc&=$aBtnIds[$i][1]&'|' EndIf Next GUICtrlSetData($idProgress,100) $sFunc=StringTrimRight($sFunc,1) ConsoleWrite('Funcs are called: '&$sFunc&@CRLF&@CRLF) EndFunc ;==>_Submit Func _exit() Exit EndFunc Func Func1() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func2() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func3() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func4() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func5() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func6() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func7() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func8() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Func Func9() Sleep(Random(100,1000,1)) GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg) EndFunc Edited April 14, 2016 by AutoBert Link to comment Share on other sites More sharing options...
faustf Posted April 15, 2016 Author Share Posted April 15, 2016 thankz Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now