Zweite GUI schließen

  • [autoit]

    Case $Message
    GUISetState(@SW_SHOW, $GUI2)

    [/autoit]

    Wenn $Message angeklickt wir, wird eine zweite GUI geöffnet bzw. der Status auf show gesetzt..
    Wenn ich dann aufs X der zweiten GUI klick beendet sich ALLES!?

  • [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Exit
    Exit
    Case $Message
    GUISetState(@SW_SHOW, $GUI2)
    ;Wenn ich bei der GUI2 auf das rote X klicke beendet sich das komplette SkripT!
    EndSwitch
    WEnd

    [/autoit]
  • Größer ist dein Script nicht ?! Mehr hast du nicht ?! häää ^^

    Edit Probiere das mal so:


    [autoit]


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Exit
    Exit
    Case $Message
    GUISetState($GUI2, @SW_SHOW)
    ;Wenn ich bei der GUI2 auf das rote X klicke beendet sich das komplette SkripT!
    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit][/autoit]
  • Doch schon aber ich will doch nur wissen was noch dazu muss dass auch wirklich NUR die zweite GUI beendet wird wenn ich bei der zweiten GUI aufs X klicke..

    Guck mal oben :) Hast du das so Probiert ?

    erst $GUI2 dann @SW_SHOW ?! Das müsste gehen.
    Wenn nicht , dan schreib mal dein ganzes script.

  • [autoit]

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

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

    $GUI = GUICreate("Form1", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message= GUICtrlCreateMenuItem("Message", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    $GUI2 = GUICreate("Info", 139, 107, 328, 363)
    $Group1 = GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_HIDE)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Message
    GUISetState(@SW_SHOW, $GUI2)
    EndSwitch
    WEnd

    [/autoit]
  • Hi,

    Spoiler anzeigen
    [autoit]

    ;
    While (True)

    $aMsg = GUIGetMsg (True)

    Switch $aMsg[0]

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

    Case $GUI_EVENT_CLOSE
    If ($aMsg[1] == $GUI) Then
    ExitLoop
    ElseIf ($aMsg[1] == $GUI2) Then
    GUIDelete ($GUI2)
    EndIf
    Case $Message
    GUISetState(@SW_SHOW, $GUI2)
    EndSwitch
    WEnd

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

    Exit (0)
    ;

    [/autoit]


    Gruß
    Greenhorn


  • So hätte ich das auch gemacht ! :) :rofl:

  • Nochmal komplett ...

    Spoiler anzeigen
    [autoit]

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

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

    Global $hGUI
    Global $hGUI2

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

    Global $Label1, $Label2, $Label3

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

    $hGUI = GUICreate("Form1", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message= GUICtrlCreateMenuItem("Message", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    Func AboutDlg ( )

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

    $hGUI2 = GUICreate("Info", 139, 107, 328, 363, _
    BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU), _
    $WS_EX_DLGMODALFRAME, $hGUI)
    GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    While (True)

    $aMsg = GUIGetMsg (True)

    Switch $aMsg[0]

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

    Case $GUI_EVENT_CLOSE
    If ($aMsg[1] == $hGUI) Then
    ExitLoop
    ElseIf ($aMsg[1] == $hGUI2) Then
    GUIDelete ($hGUI2)
    EndIf
    Case $Message
    AboutDlg ( )
    EndSwitch
    WEnd

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

    Exit (0)
    ;

    [/autoit]


    Gruß
    Greenhorn


  • Lässt sich (imho) noch leicht optimieren indem am diesen Teil:

    [autoit]


    If ($aMsg[1] == $hGUI) Then
    ExitLoop
    ElseIf ($aMsg[1] == $hGUI2) Then
    GUIDelete ($hGUI2)
    EndIf

    [/autoit]

    Auch in Switch .. Endswitch packt.

    Spoiler anzeigen
    [autoit]

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

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

    Global $hGUI
    Global $hGUI2

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

    Global $Label1, $Label2, $Label3

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

    $hGUI = GUICreate("Form1", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message= GUICtrlCreateMenuItem("Message", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    Func AboutDlg ( )

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

    $hGUI2 = GUICreate("Info", 139, 107, 328, 363, _
    BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU), _
    $WS_EX_DLGMODALFRAME, $hGUI)
    GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    While (True)

    $aMsg = GUIGetMsg (True)

    Switch $aMsg[0]

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

    Case $GUI_EVENT_CLOSE
    switch $aMsg[1]
    case $hgui
    exitloop
    case $hGUI2
    GUIDelete ($hGUI2)
    EndSwitch

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

    Case $Message
    AboutDlg ( )
    EndSwitch
    WEnd

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

    Exit (0)

    [/autoit]
    • Offizieller Beitrag

    Statt die GUI immer wieder zu löschen und neu zu erstellen, sollte man lieber mit HIDE und SHOW arbeiten:

    Spoiler anzeigen
    [autoit]


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

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

    $GUI = GUICreate("Form1", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message = GUICtrlCreateMenuItem("Message", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    $GUI2 = GUICreate("Info", 139, 107, 328, 363)
    $Group1 = GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_HIDE)

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

    While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[0]
    Case $GUI_EVENT_CLOSE
    If $aMsg[1] = $GUI Then Exit
    GUISetState(@SW_HIDE, $GUI2)
    Case $Message
    GUISetState(@SW_SHOW, $GUI2)
    EndSwitch
    WEnd

    [/autoit]
  • Ich hab das jetzt mal asprobiert mit noch mehreren GUI´s...
    Allerdings kommt da dann immer ein Fehler, sprich es lässt sich nichtmehr starten?

    Spoiler anzeigen
    [autoit]

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

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

    Global $hGUI
    Global $hGUI2
    Global $hGUI3

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

    Global $Label1, $Label2, $Label3
    Global $Group1

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

    $hGUI = GUICreate("Form", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message= GUICtrlCreateMenuItem("Message", $MenuItem1)
    $Test = GUICtrlCreateMenuItem("Test", $MenuItem1)
    $Exit = GUICtrlCreateMenuItem("Beenden", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    Func AboutDlg ( )

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

    $hGUI2 = GUICreate("Info", 139, 107, 328, 363, _
    BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU), _
    $WS_EX_DLGMODALFRAME, $hGUI)
    GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    Func AboutDlg2 ( )

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

    $hGUI3 = GUICreate("Test", 139, 91, 328, 363)
    BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU), _
    $WS_EX_DLGMODALFRAME, $hGUI)
    $Group1 = GUICtrlCreateGroup("01", 6, 4, 127, 81)
    $Label1 = GUICtrlCreateLabel("02", 16, 24, 63, 17)
    $Label2 = GUICtrlCreateLabel("03", 16, 40, 101, 17)
    $Label3 = GUICtrlCreateLabel("04", 16, 56, 103, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    While (True)

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

    $aMsg = GUIGetMsg (True)

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

    Switch $aMsg[0]

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

    Case $GUI_EVENT_CLOSE
    switch $aMsg[1]
    case $hgui
    exitloop
    case $hGUI2
    GUIDelete ($hGUI2)
    case $hGUI3
    GUIDelete ($hGUI3)
    EndSwitch

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

    Case $Message
    AboutDlg ( )
    Case $Test
    AboutDlg2 ( )
    Case $Exit
    Exit
    EndSwitch
    WEnd

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

    Exit (0)

    [/autoit]

    Kann mann da nicht einfach (wie ich es gemacht habe) weitere Funktionen einfügen?
    Oder was habe ich falsch gemacht?

  • ich denke, Du kommst mit dem Zeilenunbruch"_" durcheinander ...

    Spoiler anzeigen
    [autoit]

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

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

    Global $hGUI
    Global $hGUI2
    Global $hGUI3

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

    Global $Label1, $Label2, $Label3
    Global $Group1

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

    $hGUI = GUICreate("Form", 254, 185, 344, 251)
    $Pic2 = GUICtrlCreatePic("C:\Bild.jpg", 3, 6, 249, 157, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)
    $MenuItem1 = GUICtrlCreateMenu("&Menü")
    $Message= GUICtrlCreateMenuItem("Message", $MenuItem1)
    $Test = GUICtrlCreateMenuItem("Test", $MenuItem1)
    $Exit = GUICtrlCreateMenuItem("Beenden", $MenuItem1)
    GUISetState(@SW_SHOW)

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

    Func AboutDlg ( )

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

    $hGUI2 = GUICreate("Info", 139, 107, 328, 363, BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME)
    GUICtrlCreateGroup("Info:", 6, 4, 127, 97)
    $Label1 = GUICtrlCreateLabel("01", 16, 48, 90, 17)
    $Label2 = GUICtrlCreateLabel("02", 16, 24, 112, 17)
    $Label3 = GUICtrlCreateLabel("03", 16, 72, 83, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    Func AboutDlg2 ( )

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

    $hGUI3 = GUICreate("Test", 139, 91, 328, 363, BitOR ($WS_VISIBLE, $DS_MODALFRAME, $WS_CAPTION, $WS_SYSMENU),$WS_EX_DLGMODALFRAME)
    $Group1 = GUICtrlCreateGroup("01", 6, 4, 127, 81)
    $Label1 = GUICtrlCreateLabel("02", 16, 24, 63, 17)
    $Label2 = GUICtrlCreateLabel("03", 16, 40, 101, 17)
    $Label3 = GUICtrlCreateLabel("04", 16, 56, 103, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    EndFunc

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

    While (True)

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

    $aMsg = GUIGetMsg (True)

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

    Switch $aMsg[0]

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

    Case $GUI_EVENT_CLOSE
    switch $aMsg[1]
    case $hgui
    exitloop
    case $hGUI2
    GUIDelete ($hGUI2)
    case $hGUI3
    GUIDelete ($hGUI3)
    EndSwitch

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

    Case $Message
    AboutDlg ( )
    Case $Test
    AboutDlg2 ( )
    Case $Exit
    Exit
    EndSwitch
    WEnd

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

    Exit (0)

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Danke, jetzt fnktionierts einwandfrei!
    Zu dem "_" Zeilenbruch... Kann man das irgendwo nachlesen?

  • du hattest das im Ansatz schon richtig.
    Aber bei Dir haben sich dann Kommas und schließende Klammern eingeschlichen, die da nicht hingehörten.
    Das meinte ich damit.
    Man verliert da schon mal die Kontrolle, wo ein Befehl aufhört und so :)

    In der Hilfe findest Du eine Erklärung, wenn Du nach dem Begriff "continuation character" suchst.

    Spoiler anzeigen
    [autoit]

    Although only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceded by a blank is placed at the end of a "broken" line. String definition cannot be split in several lines, concatenation need to be used.

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

    MsgBox(4096,"", "This is a rather long line, so I " & _
    "broke it with the underscore, _, character.")

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

    The semicolon (;) is the comment character. Unless the semicolon is within a string, all text following it is ignored by the script interpreter/compiler.

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

    ; The next line contains a meaningful, end-of-line comment
    Sleep(5000) ;pause 5 seconds

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

    You can combine underscore and semicolon to put comments on lines and still have a long statement span on next line.

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

    dim $b_ ; This _ is not a continuation character, nor is the next one
    dim $k_
    Dim $a[8][2] = [ _
    [ "Word", 4 ], _ ; Comment 1
    [ "Test", 3 ], _
    [ "pi", 3.14159], _ ; Associate the name with the value
    [ "e", 2.718281828465], _ ; Same here
    [ "test;1;2;3", 123], _
    [ ';', Asc(';') ], _ ; This comment is removed, but the strings remain.
    ["", 0] ]

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

    It is also possible to comment of large blocks of script by using the #comments-start and #comments-end directives.

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Edit:
    Hat sich erledigt

    Einmal editiert, zuletzt von FreeStylaa (15. Juli 2009 um 13:38)