GordonFreeman Posted July 4, 2012 Share Posted July 4, 2012 Hello How can I do to reduce my script. who the case of the checkboxes is done 30 times expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:usersmaxdesktopprojeto frabfrabconfigform.kxf $Form1_1 = GUICreate("Frabjous Installation 1.0 - Config", 578, 378, 192, 124) GUICtrlCreateGroup("", 8, 0, 217, 273) $BoxConfig1 = GUICtrlCreateCheckbox("Box 1", 16, 16, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig3 = GUICtrlCreateCheckbox("Box 3", 16, 66, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig4 = GUICtrlCreateCheckbox("Box 4", 16, 91, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig5 = GUICtrlCreateCheckbox("Box 5", 16, 116, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig2 = GUICtrlCreateCheckbox("Box 2", 16, 41, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig6 = GUICtrlCreateCheckbox("Box 6", 16, 140, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig7 = GUICtrlCreateCheckbox("Box 7", 16, 165, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig8 = GUICtrlCreateCheckbox("Box 8", 16, 190, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig9 = GUICtrlCreateCheckbox("Box 9", 16, 215, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig10 = GUICtrlCreateCheckbox("Box 10", 16, 240, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig11 = GUICtrlCreateCheckbox("Box 11", 88, 16, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig12 = GUICtrlCreateCheckbox("Box 12", 88, 41, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig13 = GUICtrlCreateCheckbox("Box 13", 88, 66, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig14 = GUICtrlCreateCheckbox("Box 14", 88, 91, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig15 = GUICtrlCreateCheckbox("Box 15", 88, 116, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig16 = GUICtrlCreateCheckbox("Box 16", 88, 140, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig17 = GUICtrlCreateCheckbox("Box 17", 88, 165, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig18 = GUICtrlCreateCheckbox("Box 18", 88, 190, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig19 = GUICtrlCreateCheckbox("Box 19", 88, 215, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig20 = GUICtrlCreateCheckbox("Box 20", 88, 240, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig21 = GUICtrlCreateCheckbox("Box 21", 160, 16, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig22 = GUICtrlCreateCheckbox("Box 22", 160, 41, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig23 = GUICtrlCreateCheckbox("Box 23", 160, 66, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig24 = GUICtrlCreateCheckbox("Box 24", 160, 91, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig25 = GUICtrlCreateCheckbox("Box 25", 160, 116, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig26 = GUICtrlCreateCheckbox("Box 26", 160, 140, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig27 = GUICtrlCreateCheckbox("Box 27", 160, 165, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig28 = GUICtrlCreateCheckbox("Box 28", 160, 190, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig29 = GUICtrlCreateCheckbox("Box 29", 160, 215, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $BoxConfig30 = GUICtrlCreateCheckbox("Box 30", 160, 240, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", 8, 272, 217, 97) GUICtrlCreateLabel("Diretório:", 88, 280, 64, 22) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") $InputDir = GUICtrlCreateInput("", 16, 304, 201, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $ButtonSalvarDir = GUICtrlCreateButton("Salvar", 16, 336, 201, 25) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("", 232, 0, 337, 369) GUICtrlCreateLabel("Nome da Box:", 240, 16, 114, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") GUICtrlCreateLabel("Arquivo (EXE / MSI):", 240, 96, 163, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") $InputNomeBox = GUICtrlCreateInput("", 240, 56, 321, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $InputArquivo = GUICtrlCreateInput("", 240, 136, 273, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $ButtonDialogArquivo = GUICtrlCreateButton("Abrir", 520, 136, 41, 25) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateLabel("Comando:", 240, 176, 83, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") $InputComando = GUICtrlCreateInput("", 240, 216, 321, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $CheckboxAtivDesat = GUICtrlCreateCheckbox("Ativada / Desativada", 240, 256, 321, 41) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") $ButtonSalvar = GUICtrlCreateButton("Salvar", 240, 320, 321, 41) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $BoxConfigID[30] = [$BoxConfig1,$BoxConfig2,$BoxConfig3,$BoxConfig4,$BoxConfig5,$BoxConfig6,$BoxConfig7,$BoxConfig8,$BoxConfig9,$BoxConfig10,$BoxConfig11,$BoxConfig12,$BoxConfig13,$BoxConfig14,$BoxConfig15,$BoxConfig16,$BoxConfig17,$BoxConfig18,$BoxConfig19,$BoxConfig20,$BoxConfig21,$BoxConfig22,$BoxConfig23,$BoxConfig24,$BoxConfig25,$BoxConfig26,$BoxConfig27,$BoxConfig28,$BoxConfig29,$BoxConfig30] ;Preencher Dir GUICtrlSetData($InputDir, IniRead("Config.frab", "Geral", "Dir", "")) ;-->Preencher Dir While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BoxConfig1 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig1, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX1", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX1", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX1", "")) If IniRead("Config.frab", "BoxStatus", "BOX1", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX1", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig2 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig2, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX2", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX2", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX2", "")) If IniRead("Config.frab", "BoxStatus", "BOX2", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX2", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig3 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig3, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX3", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX3", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX3", "")) If IniRead("Config.frab", "BoxStatus", "BOX3", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX3", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig4 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig4, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX4", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX4", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX4", "")) If IniRead("Config.frab", "BoxStatus", "BOX4", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX4", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig5 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig5, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX5", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX5", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX5", "")) If IniRead("Config.frab", "BoxStatus", "BOX5", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX5", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig6 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig6, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX6", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX6", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX6", "")) If IniRead("Config.frab", "BoxStatus", "BOX6", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX6", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig7 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig7, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX7", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX7", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX7", "")) If IniRead("Config.frab", "BoxStatus", "BOX7", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX7", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig8 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig8, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX8", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX8", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX8", "")) If IniRead("Config.frab", "BoxStatus", "BOX8", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX8", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig9 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig9, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX9", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX9", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX9", "")) If IniRead("Config.frab", "BoxStatus", "BOX9", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX9", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig10 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig10, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX10", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX10", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX10", "")) If IniRead("Config.frab", "BoxStatus", "BOX10", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX10", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig11 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig11, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX11", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX11", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX11", "")) If IniRead("Config.frab", "BoxStatus", "BOX11", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX11", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig12 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig12, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX12", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX12", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX12", "")) If IniRead("Config.frab", "BoxStatus", "BOX12", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX12", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig13 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig13, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX13", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX13", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX13", "")) If IniRead("Config.frab", "BoxStatus", "BOX13", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX13", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig14 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig14, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX14", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX14", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX14", "")) If IniRead("Config.frab", "BoxStatus", "BOX14", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX14", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig15 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig15, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX15", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX15", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX15", "")) If IniRead("Config.frab", "BoxStatus", "BOX15", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX15", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig16 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig16, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX16", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX16", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX16", "")) If IniRead("Config.frab", "BoxStatus", "BOX16", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX16", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig17 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig17, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX17", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX17", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX17", "")) If IniRead("Config.frab", "BoxStatus", "BOX17", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX17", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig18 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig18, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX18", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX18", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX18", "")) If IniRead("Config.frab", "BoxStatus", "BOX18", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX18", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig19 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig19, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX19", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX19", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX19", "")) If IniRead("Config.frab", "BoxStatus", "BOX19", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX19", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig20 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig20, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX20", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX20", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX20", "")) If IniRead("Config.frab", "BoxStatus", "BOX20", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX20", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig21 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig21, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX21", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX21", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX21", "")) If IniRead("Config.frab", "BoxStatus", "BOX21", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX21", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig22 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig22, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX22", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX22", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX22", "")) If IniRead("Config.frab", "BoxStatus", "BOX22", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX22", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig23 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig23, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX23", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX23", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX23", "")) If IniRead("Config.frab", "BoxStatus", "BOX23", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX23", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig24 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig24, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX24", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX24", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX24", "")) If IniRead("Config.frab", "BoxStatus", "BOX24", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX24", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig25 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig25, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX25", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX25", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX25", "")) If IniRead("Config.frab", "BoxStatus", "BOX25", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX25", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig26 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig26, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX26", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX26", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX26", "")) If IniRead("Config.frab", "BoxStatus", "BOX26", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX26", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig27 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig27, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX27", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX27", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX27", "")) If IniRead("Config.frab", "BoxStatus", "BOX27", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX27", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig28 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig28, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX28", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX28", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX28", "")) If IniRead("Config.frab", "BoxStatus", "BOX28", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX28", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig29 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig29, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX29", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX29", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX29", "")) If IniRead("Config.frab", "BoxStatus", "BOX29", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX29", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $BoxConfig30 For $i = 1 to 30 GUICtrlSetState($BoxConfigID[$i - 1], $GUI_UNCHECKED) Next GUICtrlSetState($BoxConfig30, $GUI_CHECKED) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX30", "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX30", "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX30", "")) If IniRead("Config.frab", "BoxStatus", "BOX30", "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX30", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $ButtonSalvarDir IniWrite("Config.frab", "Geral", "Dir", GUICtrlRead($InputDir)) Case $ButtonDialogArquivo $FileOpenDialog = FileOpenDialog("Selecione o Arquivo:", @WorkingDir, "Executavel (*.exe)|MSI (*.msi)") GUICtrlSetData($InputArquivo, $FileOpenDialog) Case $ButtonSalvar For $i = 1 to 30 If GUICtrlRead(Execute("$BoxConfig" & $i)) = 1 Then IniWrite("Config.frab", "BoxName", "BOX" & $i, GUICtrlRead($InputNomeBox)) IniWrite("Config.frab", "BoxSetups", "BOX" & $i, GUICtrlRead($InputArquivo)) IniWrite("Config.frab", "BoxComandos", "BOX" & $i, GUICtrlRead($InputComando)) If GUICtrlRead($CheckboxAtivDesat) = 1 Then IniWrite("Config.frab", "BoxStatus", "BOX" & $i, "1") Else IniWrite("Config.frab", "BoxStatus", "BOX" & $i, "0") EndIf EndIf Next EndSwitch WEnd Frabjous Installation Link to comment Share on other sites More sharing options...
Venix Posted July 4, 2012 Share Posted July 4, 2012 (edited) May I ask why you use so many check boxes when you have it set up so that you can only select one, the whole point of a check box is that you can have multiple selections. If you want only one to be selected use a radio button. Edited July 4, 2012 by Venix Link to comment Share on other sites More sharing options...
AZJIO Posted July 4, 2012 Share Posted July 4, 2012 (edited) GUICtrlCreateRadioexpandcollapse popup#include <GUIConstantsEx.au3> #Region ### START Koda GUI section ### Form=c:usersmaxdesktopprojeto frabfrabconfigform.kxf $Form1_1 = GUICreate("Frabjous Installation 1.0 - Config", 578, 378, 192, 124) GUICtrlCreateGroup("", 8, 0, 217, 273) Global $BoxConfig[31] = [30] $x = 16 $y = 26 For $i = 1 To 30 If $i = 11 Then $x += 62 $y = 286 EndIf If $i = 21 Then $x += 72 $y = 546 EndIf $BoxConfig[$i] = GUICtrlCreateRadio("Box " & $i, $x, 16 + $i * 26 - $y, 57, 17) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") Next GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", 8, 272, 217, 97) GUICtrlCreateLabel("Diretorio:", 88, 280, 64, 22) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") $InputDir = GUICtrlCreateInput("", 16, 304, 201, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $ButtonSalvarDir = GUICtrlCreateButton("Salvar", 16, 336, 201, 25) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("", 232, 0, 337, 369) GUICtrlCreateLabel("Nome da Box:", 240, 16, 114, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") GUICtrlCreateLabel("Arquivo (EXE / MSI):", 240, 96, 163, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") $InputNomeBox = GUICtrlCreateInput("", 240, 56, 321, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $InputArquivo = GUICtrlCreateInput("", 240, 136, 273, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $ButtonDialogArquivo = GUICtrlCreateButton("Abrir", 520, 136, 41, 25) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateLabel("Comando:", 240, 176, 83, 27) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") $InputComando = GUICtrlCreateInput("", 240, 216, 321, 22) GUICtrlSetFont(-1, 9, 800, 0, "Calibri") $CheckboxAtivDesat = GUICtrlCreateCheckbox("Ativada / Desativada", 240, 256, 321, 41) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") $ButtonSalvar = GUICtrlCreateButton("Salvar", 240, 320, 321, 41) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Preencher Dir GUICtrlSetData($InputDir, IniRead("Config.frab", "Geral", "Dir", "")) ;-->Preencher Dir While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $BoxConfig[1] To $BoxConfig[30] $j = $nMsg - $BoxConfig[1] + 1 MsgBox(0, 'Сообщение', $j) GUICtrlSetData($InputNomeBox, IniRead("Config.frab", "BoxName", "BOX" & $j, "")) GUICtrlSetData($InputArquivo, IniRead("Config.frab", "BoxSetups", "BOX" & $j, "")) GUICtrlSetData($InputComando, IniRead("Config.frab", "BoxComandos", "BOX" & $j, "")) If IniRead("Config.frab", "BoxStatus", "BOX" & $j, "") = 1 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_CHECKED) ElseIf IniRead("Config.frab", "BoxStatus", "BOX1", "") = 0 Then GUICtrlSetState($CheckboxAtivDesat, $GUI_UNCHECKED) EndIf Case $ButtonSalvarDir IniWrite("Config.frab", "Geral", "Dir", GUICtrlRead($InputDir)) Case $ButtonDialogArquivo $FileOpenDialog = FileOpenDialog("Selecione o Arquivo:", @WorkingDir, "Executavel (*.exe)|MSI (*.msi)") GUICtrlSetData($InputArquivo, $FileOpenDialog) Case $ButtonSalvar For $i = 1 To 30 If GUICtrlRead($BoxConfig[$i]) = 1 Then IniWrite("Config.frab", "BoxName", "BOX" & $i, GUICtrlRead($InputNomeBox)) IniWrite("Config.frab", "BoxSetups", "BOX" & $i, GUICtrlRead($InputArquivo)) IniWrite("Config.frab", "BoxComandos", "BOX" & $i, GUICtrlRead($InputComando)) If GUICtrlRead($CheckboxAtivDesat) = 1 Then IniWrite("Config.frab", "BoxStatus", "BOX" & $i, "1") Else IniWrite("Config.frab", "BoxStatus", "BOX" & $i, "0") EndIf EndIf Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEndGUISetCoord, GUICoordMode Edited July 4, 2012 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
GordonFreeman Posted July 4, 2012 Author Share Posted July 4, 2012 (edited) Nice. I like ask because it opens the mind to various ideas.$nMsg = GUIGetMsg()1. So here, the func returns the Control ID to be used in the switch? right?I never paid attention in this part because Koda creates automatic.2. And why: $BoxConfig[31] = [30]3. and you created the boxes at the start of the form to be easier to interact with them? right? Since then they started with ID 1, 2, 3...But is not saving the config, because it will be? Edited July 4, 2012 by GordonFreeman Frabjous Installation Link to comment Share on other sites More sharing options...
AZJIO Posted July 4, 2012 Share Posted July 4, 2012 1. Yes 2. And why: $BoxConfig[31] = [30]similarly StringSplit For $i = 1 To $BoxConfig[0] My other projects or all Link to comment Share on other sites More sharing options...
GordonFreeman Posted July 4, 2012 Author Share Posted July 4, 2012 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case 1 To 30 Here is one of the errors. In theory, only run the command when the "jump" from control 1 to the control 30 That is. When the control 1 is marked and i click on the control 30 But I appreciate the help. I'm trying any at all costs. If someone can help thank you too. Frabjous Installation Link to comment Share on other sites More sharing options...
pieeater Posted July 4, 2012 Share Posted July 4, 2012 not sure about the rest but $BoxConfig[30] == $BoxConfig[31] because arrays start from the value zero. so $BoxConfig[0] == the first value, $BoxConfig[1] == the second and so on. [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
AZJIO Posted July 4, 2012 Share Posted July 4, 2012 (edited) GordonFreeman Fixed I did not bother checking, because I did not have the ini-file Edited July 4, 2012 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
GordonFreeman Posted July 4, 2012 Author Share Posted July 4, 2012 May I ask why you use so many check boxes when you have it set up so that you can only select one, the whole point of a check box is that you can have multiple selections. If you want only one to be selected use a radio button.really, a attention error, since the other part of the script is with checkboxesBig thanks to AZJIO, not only i solved a problem as I learned more. Frabjous Installation 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