Hallo zusammen,
ich habe eine Gui geschrieben wo hinter jeder Checkbox später mal ein Programm hinterlegt sein soll.
das prinzip mit der "GUICtrlRead($Checkbox1), $GUI_CHECKED" habe ich verstanden, aber wenn ihr die source mal seht dann könnt ihr auch verstehen das die zeilen ewig lang werden wenn ich das zusammen alles verknüpfen will.
kann man das alles etwas vereinfachen?
so das am schluss einmal der Check für alle Checkboxen kommt, was markiert ist und was nicht und dann das entsprechende ausgeführt wird?
Spoiler anzeigen
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Programm Auswahl", 500, 300, -1, -1)
$Button1 = GUICtrlCreateButton("Starten", 400, 250)
$Button2 = GUICtrlCreateButton("Exit", 450, 250)
$Checkbox1 = GUICtrlCreateCheckbox("Prog1 ", 50, 50, 80)
$Checkbox2 = GUICtrlCreateCheckbox("Prog2 ", 50, 70, 80)
$Checkbox3 = GUICtrlCreateCheckbox("Prog3 ", 50, 90, 80)
$Checkbox4 = GUICtrlCreateCheckbox("Prog4 ", 50, 110, 80)
$Checkbox5 = GUICtrlCreateCheckbox("Prog5 ", 50, 130, 80)
$Checkbox6 = GUICtrlCreateCheckbox("Prog6 ", 50, 150, 80)
$Checkbox7 = GUICtrlCreateCheckbox("Prog7 ", 200, 50, 80)
$Checkbox8 = GUICtrlCreateCheckbox("Prog8 ", 200, 70, 80)
$Checkbox9 = GUICtrlCreateCheckbox("Prog9 ", 200, 90, 80)
$Checkbox10 = GUICtrlCreateCheckbox("Prog10 ", 200, 110, 80)
$Checkbox11 = GUICtrlCreateCheckbox("Prog11 ", 200, 130, 80)
$Checkbox12 = GUICtrlCreateCheckbox("Prog12 ", 200, 150, 80)
$menu1 = GUICtrlCreateMenu("&Options")
$menu11 = GUICtrlCreateMenuItem("Leer1", $menu1)
$menu12 = GUICtrlCreateMenuItem("Leer2", $menu1)
$menu13 = GUICtrlCreateMenuItem("Exit", $menu1)
$menu2 = GUICtrlCreateMenu("&Help")
$menu21 = GUICtrlCreateMenuItem("Info", $menu2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
;soll aufgehen, wenn Checkbox 1, 2 und 3 ausgewählt ist und ein Button über das GUI gedrückt wird.
If BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) And BitAnd(GUICtrlRead($Checkbox2), $GUI_CHECKED) And BitAnd(GUICtrlRead($Checkbox3), $GUI_CHECKED) then
msgbox(0,"Prog 1, 2 und 3","Prog 1, 2 und 3")
Exit
;soll aufgehen, wenn Checkbox 1 und 3 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) And BitAnd(GUICtrlRead($Checkbox3), $GUI_CHECKED) then
Msgbox(0,"Prog 1 und 3","Prog 1 und 3")
Exit
;soll aufgehen, wenn Checkbox 1 und 2 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) And BitAnd(GUICtrlRead($Checkbox2), $GUI_CHECKED) then
msgbox(0,"Prog 1 und 2","Prog 1 und 2")
Exit
;soll aufgehen, wenn Checkbox 2 und 3 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox2), $GUI_CHECKED) And BitAnd(GUICtrlRead($Checkbox3), $GUI_CHECKED) then
msgbox(0,"Prog 2 und 3","Prog 2 und 3")
Exit
;funktioniert: soll aufgehen, wenn NUR Checkbox 3 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox3), $GUI_CHECKED) then
msgbox(0,"Prog 3","Prog 3")
Exit
;funktioniert: soll aufgehen, wenn NUR Checkbox 2 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox2), $GUI_CHECKED) then
msgbox(0,"Prog 2","Prog 2")
Exit
;funktioniert: soll aufgehen, wenn NUR Checkbox 1 ausgewählt ist und ein Button über das GUI gedrückt wird.
ElseIf BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED)then
msgbox(0,"Prog 1","Prog 1 ")
Exit
Else
msgbox(0,"Keine Software ausgewählt","Keine Software ausgewählt")
Exit
EndIf
case $Button2
Exit
case $menu13
Exit
Case $menu21
msgbox(0,"Infobox","Geschrieben von",5)
EndSwitch
WEnd
; evtl. hilfsmittel
[/autoit] [autoit][/autoit] [autoit];~ $Radio1 = GUICtrlCreateRadio("Radio1", 8, 136, 57, 33)
;~ $Radio2 = GUICtrlCreateRadio("Radio2", 8, 176, 57, 41)