MsgBox Generator - Die 128ste

  • Hi,

    mir ist bewusst, dass es schon diverse dieser Tools gibt (auch hier im Forum), auch weiss ich, dass man einen Generator in SciTE mit "Alt+W" aufrufen kann :)

    Trotzdem möchte ich euch mein Werk nicht vorenthalten:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $msgbox = GUICreate("MsgBox-Generator", 366, 507, 373, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $btn0 = GUICtrlCreateRadio("OK", 16, 32, 33, 17)
    $btn1 = GUICtrlCreateRadio("OK und Abbrechen", 16, 48, 113, 17)
    $btn2 = GUICtrlCreateRadio("Abbrechen, Wiederholen, Ignorieren", 16, 64, 193, 17)
    $btn3 = GUICtrlCreateRadio("Ja, Nein, Abbrechen", 16, 80, 121, 17)
    $btn4 = GUICtrlCreateRadio("Ja und Nein", 16, 96, 81, 17)
    $btn5 = GUICtrlCreateRadio("Wiederholen und Abbrechen", 16, 112, 161, 17)
    $btn6 = GUICtrlCreateRadio("Abbrechen, Wiederholen, Weiter", 16, 128, 177, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $std0 = GUICtrlCreateRadio("Erster Button", 224, 32, 81, 17)
    $std1 = GUICtrlCreateRadio("Zweiter Button", 224, 48, 89, 17)
    $std2 = GUICtrlCreateRadio("Dritter Button", 224, 64, 81, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $ic0 = GUICtrlCreateRadio("Kein Icon", 16, 168, 65, 17)
    $ic1 = GUICtrlCreateRadio("Stopp-Zeichen", 16, 184, 89, 17)
    $ic2 = GUICtrlCreateRadio("Fragezeichen", 16, 200, 89, 17)
    $ic3 = GUICtrlCreateRadio("Ausrufezeichen", 16, 216, 97, 17)
    $ic4 = GUICtrlCreateRadio("Information", 16, 232, 73, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $mod0 = GUICtrlCreateRadio("Anwendung", 224, 200, 81, 17)
    $mod1 = GUICtrlCreateRadio("System-modal", 224, 216, 89, 17)
    $mod2 = GUICtrlCreateRadio("Task-modal", 224, 232, 81, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $son0 = GUICtrlCreateRadio("nichts weiteres", 224, 104, 113, 17)
    $son1 = GUICtrlCreateRadio("immer im Vordergrund", 224, 120, 121, 17)
    $son2 = GUICtrlCreateRadio("Text rechtsbündig", 224, 136, 105, 17)
    $Label1 = GUICtrlCreateLabel("Buttons:", 16, 16, 43, 17)
    $Label2 = GUICtrlCreateLabel("Icon:", 16, 152, 28, 17)
    $Label3 = GUICtrlCreateLabel("Standard Button:", 224, 16, 84, 17)
    $Label4 = GUICtrlCreateLabel("Sonstiges:", 224, 88, 53, 17)
    $Label5 = GUICtrlCreateLabel("Modalität:", 224, 184, 50, 17)
    $Label6 = GUICtrlCreateLabel("Ausgabe:", 16, 448, 49, 17)
    $out = GUICtrlCreateInput("", 16, 472, 329, 21)
    $go = GUICtrlCreateButton("MsgBox Generieren", 16, 384, 331, 41, $WS_GROUP)
    $Label7 = GUICtrlCreateLabel("Titel:", 16, 256, 27, 17)
    $ititel = GUICtrlCreateInput("Überschrift", 16, 280, 329, 21)
    $Label8 = GUICtrlCreateLabel("Text:", 16, 304, 28, 17)
    $itext = GUICtrlCreateInput("Ich bin eine Msgbox!", 16, 328, 329, 21)
    $testing = GUICtrlCreateCheckbox("Testen?", 280, 440, 65, 17)
    GUICtrlSetState($testing,$GUI_CHECKED)
    $Label9 = GUICtrlCreateLabel("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _", 16, 352, 340, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($btn0,$GUI_CHECKED)
    GUICtrlSetState($std0,$GUI_CHECKED)
    GUICtrlSetState($ic0,$GUI_CHECKED)
    GUICtrlSetState($mod0,$GUI_CHECKED)
    GUICtrlSetState($son0,$GUI_CHECKED)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $go
    generate()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    func generate()
    Local $test
    Local $flag = 0
    Local $titel = GUICtrlRead($ititel)
    Local $text = GUICtrlRead($itext)

    [/autoit] [autoit][/autoit] [autoit]

    if GUICtrlRead($btn0) = 1 Then $flag += 0
    if GUICtrlRead($btn1) = 1 Then $flag += 1
    if GUICtrlRead($btn2) = 1 Then $flag += 2
    if GUICtrlRead($btn3) = 1 Then $flag += 3
    if GUICtrlRead($btn4) = 1 Then $flag += 4
    if GUICtrlRead($btn5) = 1 Then $flag += 5
    if GUICtrlRead($btn6) = 1 Then $flag += 6
    if GUICtrlRead($ic0) = 1 Then $flag += 0
    if GUICtrlRead($ic1) = 1 Then $flag += 16
    if GUICtrlRead($ic2) = 1 Then $flag += 32
    if GUICtrlRead($ic3) = 1 Then $flag += 48
    if GUICtrlRead($ic4) = 1 Then $flag += 64
    if GUICtrlRead($mod0) = 1 Then $flag += 0
    if GUICtrlRead($mod1) = 1 Then $flag += 4096
    if GUICtrlRead($mod2) = 1 Then $flag += 8192
    if GUICtrlRead($std0) = 1 Then $flag += 0
    if GUICtrlRead($std1) = 1 Then $flag += 256
    if GUICtrlRead($std2) = 1 Then $flag += 512
    if GUICtrlRead($son0) = 1 Then $flag += 0
    if GUICtrlRead($son1) = 1 Then $flag += 262144
    if GUICtrlRead($son2) = 1 Then $flag += 524288

    [/autoit] [autoit][/autoit] [autoit]

    $test = 'MsgBox(' & $flag & ',"' & $titel & '","' & $text & '")'

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($out,$test)

    [/autoit] [autoit][/autoit] [autoit]

    if GUICtrlRead($testing) = 1 then Execute($test)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]

    Hoffe das Teil gefällt euch :)

    (Die Aus-/Eingabezeilen scheinen etwas zu kurz geraten, das tut der Funktion aber keinen Abbruch)

    Gruß
    x0r

    Simon nörgelt, Simon nervt - aber Simon verbessert die Welt. Glaubt er.

  • Nicht dass es bei einer solchen, schnellen und einmaligen Ausführung Sinn ergeben würde, aber: If-Abfragen sind teuer, wenn du viele hintereinander hast, nimm lieber Select. Außerdem verbessert es die Übersicht. Manche Zeilen kannst du außerdem ersatzlos streichen (die mit dem "+= 0").

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

  • Hi,

    danke für dein Feedback.

    Das mit Select hab ich versucht, allerdings ist dann die Variable $flag entweder immer "0" oder es wird der neue Wert zum alten addiert.

    Die ganzen "+= 0" hab ich mal rausgenommen, diente nur der Übersicht halber :whistling:

    Gruß
    x0r

    Simon nörgelt, Simon nervt - aber Simon verbessert die Welt. Glaubt er.

  • mit select():

    [autoit]

    Select
    Case GUICtrlRead($btn1) = 1
    $flag += 1
    Case GUICtrlRead($btn2) = 1
    $flag += 2
    Case GUICtrlRead($btn3) = 1
    $flag += 3
    Case GUICtrlRead($btn4) = 1
    $flag += 4
    Case GUICtrlRead($btn5) = 1
    $flag += 5
    Case GUICtrlRead($btn6) = 1
    $flag += 6
    EndSelect
    Select
    Case GUICtrlRead($ic1) = 1
    $flag += 16
    Case GUICtrlRead($ic2) = 1
    $flag += 32
    Case GUICtrlRead($ic3) = 1
    $flag += 48
    Case GUICtrlRead($ic4) = 1
    $flag += 64
    EndSelect
    Select
    Case GUICtrlRead($mod1) = 1
    $flag += 4096
    Case GUICtrlRead($mod2) = 1
    $flag += 8192
    EndSelect
    Select
    Case GUICtrlRead($std1) = 1
    $flag += 256
    Case GUICtrlRead($std2) = 1
    $flag += 512
    EndSelect
    Select
    Case GUICtrlRead($son1) = 1
    $flag += 262144
    Case GUICtrlRead($son2) = 1
    $flag += 524288
    EndSelect

    [/autoit]

    aber obs so wirklich übersichtlicher wird ist fraglich.... ich hätts jetzt sowieso lieber mit comboboxen gemacht...

  • er meinte vermutlich übersichtlicher vom code her
    aber da der code hierbei nicht wirklich zur letztendlichen funktion beiträgt, ist das schnuppe wie der aussieht (würd ich behaupten!)

    comboboxen haben halt den nachteil, dass du ewig rumklicken darfst, bis du die option gefunden hast - bei radiobuttons hast alles auf 1 blick und 1 klick :D

    ausserdem hat mich das gruppieren der radiobuttons sehr interessiert, wusste bis dahin noch gar nicht, dass die möglichkeit besteht

    Simon nörgelt, Simon nervt - aber Simon verbessert die Welt. Glaubt er.

  • K4z: In deinem Code kann man noch alle Auftreten Select und EndSelect außer dem ersten und letzten weglassen. Dann ist es imho übersichtlicher

    Zitat

    aber da der code hierbei nicht wirklich zur letztendlichen funktion beiträgt, ist das schnuppe wie der aussieht (würd ich behaupten!)


    Jein. Bei diesem Skript mag das stimmen, aber es ist gut, wenn man sich gleich angewöhnt, übersichtlich zu coden, wenn die Skripte dann später länger und komplizierter werden.

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

  • Nein kann man nich:D Wenn ein case zutrifft, dann ist das eine Abbruchbedingung für die Selectschleife, dadurch würde dann zum Beispiel das selectieren von nem Icon vom Script gar nicht realisiert werden...

  • Vielleicht noch eine kleine Anregung, wie man das mit ner Whileschleife abfragen könnte, man muss allerdings dann seine Variablen geschickt benennen...
    Ach und ich würd aus den RadioButtons bei Sonsitges Checkboxen machen, da beides gleichzeitig zutreffen kann.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #region GUI
    $hGui = GUICreate("MsgBox-Generator", 366, 507, 373, 20)
    GUICtrlCreateLabel("Icon:", 16, 152, 28, 17)
    GUICtrlCreateLabel("Standard Button:", 224, 16, 84, 17)
    GUICtrlCreateLabel("Sonstiges:", 224, 88, 53, 17)
    GUICtrlCreateLabel("Modalität:", 224, 184, 50, 17)
    GUICtrlCreateLabel("Ausgabe:", 16, 448, 49, 17)
    GUICtrlCreateLabel("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _", 16, 352, 340, 17)
    GUICtrlCreateLabel("Titel:", 16, 256, 27, 17)
    GUICtrlCreateLabel("Text:", 16, 304, 28, 17)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hRadio0= GUICtrlCreateRadio("OK", 16, 32, 33, 17)
    $hRadio1 = GUICtrlCreateRadio("OK und Abbrechen", 16, 48, 113, 17)
    $hRadio2 = GUICtrlCreateRadio("Abbrechen, Wiederholen, Ignorieren", 16, 64, 193, 17)
    $hRadio3 = GUICtrlCreateRadio("Ja, Nein, Abbrechen", 16, 80, 121, 17)
    $hRadio4 = GUICtrlCreateRadio("Ja und Nein", 16, 96, 81, 17)
    $hRadio5 = GUICtrlCreateRadio("Wiederholen und Abbrechen", 16, 112, 161, 17)
    $hRadio6 = GUICtrlCreateRadio("Abbrechen, Wiederholen, Weiter", 16, 128, 177, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hRadio7 = GUICtrlCreateRadio("Erster Button", 224, 32, 81, 17)
    $hRadio8 = GUICtrlCreateRadio("Zweiter Button", 224, 48, 89, 17)
    $hRadio9 = GUICtrlCreateRadio("Dritter Button", 224, 64, 81, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hRadio10 = GUICtrlCreateRadio("Kein Icon", 16, 168, 65, 17)
    $hRadio11 = GUICtrlCreateRadio("Stopp-Zeichen", 16, 184, 89, 17)
    $hRadio12 = GUICtrlCreateRadio("Fragezeichen", 16, 200, 89, 17)
    $hRadio13 = GUICtrlCreateRadio("Ausrufezeichen", 16, 216, 97, 17)
    $hRadio14 = GUICtrlCreateRadio("Information", 16, 232, 73, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hRadio15 = GUICtrlCreateRadio("Anwendung", 224, 200, 81, 17)
    $hRadio16 = GUICtrlCreateRadio("System-modal", 224, 216, 89, 17)
    $hRadio17 = GUICtrlCreateRadio("Task-modal", 224, 232, 81, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hRadio18 = GUICtrlCreateCheckbox("immer im Vordergrund", 224, 104, 121, 17)
    $hRadio19 = GUICtrlCreateCheckbox("Text rechtsbündig", 224, 120, 105, 17)
    $hRadio20 = GUICtrlCreateLabel("Buttons:", 16, 16, 43, 17)

    [/autoit] [autoit][/autoit] [autoit]

    $hInptOut = GUICtrlCreateInput("", 16, 472, 329, 21)
    $hInptTitle = GUICtrlCreateInput("Überschrift", 16, 280, 329, 21)
    $hInptText = GUICtrlCreateInput("Ich bin eine Msgbox!", 16, 328, 329, 21)
    $hCheckTest = GUICtrlCreateCheckbox("Testen?", 280, 440, 65, 17)
    $hBtnGo = GUICtrlCreateButton("MsgBox Generieren", 16, 384, 331, 41, $WS_GROUP)
    GUICtrlSetState($hRadio0,$GUI_CHECKED)
    GUICtrlSetState($hRadio7,$GUI_CHECKED)
    GUICtrlSetState($hRadio10,$GUI_CHECKED)
    GUICtrlSetState($hRadio15,$GUI_CHECKED)
    GUICtrlSetState($hCheckTest,$GUI_CHECKED)
    GUISetState(@SW_SHOW)
    #endregion GUI

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $hBtnGo
    generate()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    func generate()
    Local $sResult, $flag = 0, $titel = GUICtrlRead($hInptTitle), $text = GUICtrlRead($hInptText)
    Dim $aFlags[20]=[0,1,2,3,4,5,6,0,256,512,0,16,32,48,64,0,4096,8192,262144,524288]

    [/autoit] [autoit][/autoit] [autoit]

    For $iI=0 To 19 Step 1
    If GUICtrlRead(Eval("hRadio" & $iI)) = 1 Then
    $flag += $aFlags[$iI]
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $sResult = StringFormat('MsgBox(%i, "%s", "%s")', $flag, $titel, $text)
    GUICtrlSetData($hInptOut,$sResult)
    If GUICtrlRead($hCheckTest) = 1 Then Execute($sResult)
    EndFunc

    [/autoit]
    Zitat

    You just keep on trying 'till you run out of cake. ;)


    [STEAM] Source UDF

    2 Mal editiert, zuletzt von K4z (21. Januar 2012 um 13:55)