Wie 1. GUI schließen und 2. anzeigen lassen?

  • also in meinem Programm erscheint erstmal eine gui wo man einen Pfad angeben soll und dann auf "übernehmen" klicken soll. Danach wird die GUI geschlossen und die nächsten GUI soll geöffnet werden. Ich hab schon einiges ausprobiert, aber statt zu die 2. GUI anzuzeigen beendet er nur das Skript. Hat einer ne Idee? oder kannmir sagen was ich flasch gemacht habe?

    Nicht wundern, das Programm ist in der aufbauphase noch beiweitem!!! daher gehen einige funktionen nicht etc.

    danke für Hilfe!

    Spoiler anzeigen
    [autoit]

    #Include <Array.au3>
    #Include <File.au3>
    #include <GUIConstantsEx.au3>
    #Include <GuiListBox.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)
    ;Window1
    Global $x=0

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

    $pfadWIn=GUICreate("Pfadangabe", 250, 300)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents")
    GUISetState(@SW_SHOW, $pfadWin)
    $pfad=GUICtrlCreateInput("D:\Setups", 10, 30)
    $pfadbutton=GUICtrlCreateButton("Übernehmen", 50, 100)
    GUICtrlSetOnEvent($pfadbutton, "_uebernehmen")

    While True
    Sleep(10)
    WEnd
    ;Func _uebernehmen()
    ;Window2
    If $x=1 Then
    $mainWindow=GUICreate("Installer", 510, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents")
    GUISetState(@SW_SHOW, $mainWindow)
    ;Listbox
    $programmlistelinks=_GUICtrlListBox_Create($mainWindow, "", 10, 30, 200, 450, BitOr($WS_VSCROLL,$LBS_EXTENDEDSEL,$LBS_SORT))
    $programmlisterechts=_GUICtrlListBox_Create($mainWindow, "", 300, 30, 200, 450, BitOr($WS_VSCROLL,$LBS_EXTENDEDSEL,$LBS_SORT))
    ;Menüs
    $menu1=GUICtrlCreateMenu("Datei")
    $menu2=GUICtrlCreateMenu("Extras")
    $menu3=GUICtrlCreateMenu("Info")
    $menu21=GUICtrlCreateMenu("Zählen", $menu2)
    $verSetups=GUICtrlCreateMenuItem("Vergübare Setups", $menu21)
    $ausSetups=GUICtrlCreateMenuItem("Ausgewählte Setups", $menu21)
    $menu11=GUICtrlCreateMenuItem("Pfadangabe", $menu1)
    $menu12=GUICtrlCreateMenuItem("beenden", $menu1)
    GUICtrlSetOnEvent($menu11, "_pfadangabe")
    GUICtrlSetOnEvent($menu12, "_beenden")
    GUICtrlSetOnEvent($verSetups, "_anzahlboxlinks")
    GUICtrlSetOnEvent($ausSetups, "_anzahlboxrechts")
    ;Buttons
    $button0=GUICtrlCreateButton("T", 10, 5, 30, 25)
    $button1=GUICtrlCreateButton(">", 240, 100, 30, 25)
    $button2=GUICtrlCreateButton("A>", 240, 150, 30, 25)
    $button3=GUICtrlCreateButton("X", 240, 200, 30, 25)
    $button4=GUICtrlCreateButton("<X", 240, 250, 30, 25)
    $button5=GUICtrlCreateButton("SETUP", 450, 545)
    GUICtrlSetOnEvent($button0, "_test")
    GUICtrlSetOnEvent($button1, "_auswahl")
    GUICtrlSetOnEvent($button2, "_auswahlGesamt")
    GUICtrlSetOnEvent($button3, "_cancel")
    GUICtrlSetOnEvent($button4, "_cancelGesamt")
    GUICtrlSetOnEvent($button5, "_setup")
    ;Global $pfad=
    $progress=GUICtrlCreateProgress(10, 510, 490, 20)
    $progressInformation=GUICtrlCreateLabel("Momentan wird installiert: < Derzeit läuft keine Installation >", 10, 480, 300)
    ; Pfad auf den Ordner in dem deine Installationsordner liegen sollen
    $programme=_FileListToArray("D:\Setups")
    ; #Hier wird die linke Listcontrol mit den Ordnernamen unterhalb des von dir angegebenen Verzeichnisses gefüllt
    For $i=1 To $programme[0]
    _GUICtrlListBox_AddString($programmlistelinks, $programme[$i])
    Next
    ;EndFunc
    EndIf

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

    Func _GUIEvents()
    Select
    Case @GUI_CtrlId = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    EndFunc

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

    ; #Die Funktion _auswahlGesamt() markiert zuerst alle Einträge der linken Control und füllt danach die rechte mit den entsprechenden Einträgen auf
    Func _auswahlGesamt()
    _GUICtrlListBox_SetSel($programmlistelinks, -1)
    $i=0
    If _GUICtrlListBox_GetText($programmlistelinks, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlistelinks, $i)=True Then
    _GUICtrlListBox_AddString($programmlisterechts, _GUICtrlListBox_GetText($programmlistelinks, $i))
    _GUICtrlListBox_DeleteString($programmlistelinks, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlistelinks)
    EndIf
    EndFunc

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

    Func _auswahl()
    $i=0
    If _GUICtrlListBox_GetText($programmlistelinks, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlistelinks, $i)=True Then
    _GUICtrlListBox_AddString($programmlisterechts, _GUICtrlListBox_GetText($programmlistelinks, $i))
    _GUICtrlListBox_DeleteString($programmlistelinks, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlistelinks)
    EndIf
    EndFunc

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

    Func _cancel()
    $i=0
    If _GUICtrlListBox_GetText($programmlisterechts, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlisterechts, $i)=True Then
    _GUICtrlListBox_AddString($programmlistelinks, _GUICtrlListBox_GetText($programmlisterechts, $i))
    _GUICtrlListBox_DeleteString($programmlisterechts, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlisterechts)
    EndIf
    EndFunc

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

    ; #Die Funktion _cancelGesamt; genau andersrum wie auswahlGesamt()
    Func _cancelGesamt()
    _GUICtrlListBox_SetSel($programmlisterechts, -1)
    $i=0
    If _GUICtrlListBox_GetText($programmlisterechts, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlisterechts, $i)=True Then
    _GUICtrlListBox_AddString($programmlistelinks, _GUICtrlListBox_GetText($programmlisterechts, $i))
    _GUICtrlListBox_DeleteString($programmlisterechts, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlisterechts)
    EndIf
    EndFunc
    ; installieren
    Func _setup()
    If _GUICtrlListBox_GetCount($programmlisterechts)<>0 Then
    $s=0
    For $i = 0 To _GUICtrlListBox_GetCount($programmlisterechts)
    $programmSetup=_GUICtrlListBox_GetText($programmlisterechts, $i)
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < " & $programmSetup & " >")
    Run("D:\Setups\" & $programmSetup)
    ProcessWaitClose("autoinstall.exe")
    $s+=(100/_GUICtrlListBox_GetCount($programmlisterechts))
    GUICtrlSetData($progress, $s)
    Next
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < Installationsvorgang beendet >")
    Sleep(1500)
    _cancelGesamt()
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < Derzeit läuft keine Installation >")
    GUICtrlSetData($progress, 0)
    Else
    MsgBox(64,"Message", "Keine Setups ausgewählt!")
    EndIf
    EndFunc

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

    Func _anzahlboxlinks()
    MsgBox(4160, "Information", "Anzahl: " & _GUICtrlListBox_GetCount($programmlistelinks))
    EndFunc

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

    Func _anzahlboxrechts()
    MsgBox(4160, "Information", "Anzahl: " & _GUICtrlListBox_GetCount($programmlisterechts))
    EndFunc
    ;PFADWINDOW---------------------------
    Func _pfadangabe()

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



    $pfad=GUICtrlCreateInput("D:\Setups", 10, 30)
    $knopf=GUICtrlCreateButton("Übernehmen", 100, 100)
    GUICtrlSetOnEvent($knopf, "_uebernehmen")

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

    EndFunc
    ;-------------------------------------
    Func _test()
    ;GUISetState(@GUI_CTRLId = $GUI_EVENT_CLOSE)
    MsgBox( 0, "E", "test erfolg")
    ;WinClose("test")
    EndFunc

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

    Func _beenden()
    Exit
    EndFunc

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

    Func _uebernehmen()
    $x=1
    ;WinSetState("Installer", "", @SW_SHOW)
    Winclose("Pfadangabe")
    EndFunc

    [/autoit]

    4 Mal editiert, zuletzt von NSBM (26. August 2009 um 19:20)

  • ahhh... danke.. das klingt logisch . da hätte ich auch selber drauf kommen können. :D :P

    ich danke dir!

  • Ich bekomm es aber trotzdem nicht. auch wenn ich die schleife wegnehme, wo anders hinsetze. EIne Do schleife nehme die nur so lange geht bis §x=1 ist wo ja die 2. GUI entstehen soll

    • Offizieller Beitrag

    Hier hat du was zum weiterwursteln:

    Spoiler anzeigen
    [autoit]

    #cs **************************************************************************

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

    Wie 1. GUI schließen und 2. anzeigen lassen?

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

    http://www.autoit.de/index.php?page…9677#post109677

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

    #ce **************************************************************************

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

    #Include <Array.au3>
    #Include <File.au3>
    #include <GUIConstantsEx.au3>
    #Include <GuiListBox.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)
    ;Window1
    Global $x=0

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

    Global $pfadWIn=GUICreate("Pfadangabe", 250, 300)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents")
    Global $pfad=GUICtrlCreateInput("D:\Setups", 10, 30)
    Global $pfadbutton=GUICtrlCreateButton("Übernehmen", 50, 100)
    GUICtrlSetOnEvent($pfadbutton, "_uebernehmen")
    GUISetState(@SW_SHOW, $pfadWin)

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

    Global $mainWindow=GUICreate("Installer", 510, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents")
    ;Listbox
    Global $programmlistelinks=_GUICtrlListBox_Create($mainWindow, "", 10, 30, 200, 450, BitOr($WS_VSCROLL,$LBS_EXTENDEDSEL,$LBS_SORT))
    Global $programmlisterechts=_GUICtrlListBox_Create($mainWindow, "", 300, 30, 200, 450, BitOr($WS_VSCROLL,$LBS_EXTENDEDSEL,$LBS_SORT))
    ;Menüs
    Global $menu1=GUICtrlCreateMenu("Datei")
    Global $menu2=GUICtrlCreateMenu("Extras")
    Global $menu3=GUICtrlCreateMenu("Info")
    Global $menu21=GUICtrlCreateMenu("Zählen", $menu2)
    Global $verSetups=GUICtrlCreateMenuItem("Vergübare Setups", $menu21)
    Global $ausSetups=GUICtrlCreateMenuItem("Ausgewählte Setups", $menu21)
    Global $menu11=GUICtrlCreateMenuItem("Pfadangabe", $menu1)
    Global $menu12=GUICtrlCreateMenuItem("beenden", $menu1)
    GUICtrlSetOnEvent($menu11, "_pfadangabe")
    GUICtrlSetOnEvent($menu12, "_beenden")
    GUICtrlSetOnEvent($verSetups, "_anzahlboxlinks")
    GUICtrlSetOnEvent($ausSetups, "_anzahlboxrechts")
    ;Buttons
    Global $button0=GUICtrlCreateButton("T", 10, 5, 30, 25)
    Global $button1=GUICtrlCreateButton(">", 240, 100, 30, 25)
    Global $button2=GUICtrlCreateButton("A>", 240, 150, 30, 25)
    Global $button3=GUICtrlCreateButton("X", 240, 200, 30, 25)
    Global $button4=GUICtrlCreateButton("<X", 240, 250, 30, 25)
    Global $button5=GUICtrlCreateButton("SETUP", 450, 545)
    GUICtrlSetOnEvent($button0, "_test")
    GUICtrlSetOnEvent($button1, "_auswahl")
    GUICtrlSetOnEvent($button2, "_auswahlGesamt")
    GUICtrlSetOnEvent($button3, "_cancel")
    GUICtrlSetOnEvent($button4, "_cancelGesamt")
    GUICtrlSetOnEvent($button5, "_setup")
    ;Global $pfad=
    Global $progress=GUICtrlCreateProgress(10, 510, 490, 20)
    Global $progressInformation=GUICtrlCreateLabel("Momentan wird installiert: < Derzeit läuft keine Installation >", 10, 480, 300)

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

    GUISetState(@SW_HIDE, $mainWindow)
    ;Pfad auf den Ordner in dem deine Installationsordner liegen sollen
    Func _SetData()
    Global $programme =_FileListToArray(GUICtrlRead($PFad))
    ; #Hier wird die linke Listcontrol mit den Ordnernamen unterhalb des von dir angegebenen Verzeichnisses gefüllt
    For $i=1 To $programme[0]
    _GUICtrlListBox_AddString($programmlistelinks, $programme[$i])
    Next
    EndFunc

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

    While True
    Sleep(10)
    WEnd

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

    Func _GUIEvents()
    Select
    Case @GUI_CtrlId = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    EndFunc

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

    ; #Die Funktion _auswahlGesamt() markiert zuerst alle Einträge der linken Control und füllt danach die rechte mit den entsprechenden Einträgen auf
    Func _auswahlGesamt()
    _GUICtrlListBox_SetSel($programmlistelinks, -1)
    $i=0
    If _GUICtrlListBox_GetText($programmlistelinks, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlistelinks, $i)=True Then
    _GUICtrlListBox_AddString($programmlisterechts, _GUICtrlListBox_GetText($programmlistelinks, $i))
    _GUICtrlListBox_DeleteString($programmlistelinks, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlistelinks)
    EndIf
    EndFunc

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

    Func _auswahl()
    $i=0
    If _GUICtrlListBox_GetText($programmlistelinks, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlistelinks, $i)=True Then
    _GUICtrlListBox_AddString($programmlisterechts, _GUICtrlListBox_GetText($programmlistelinks, $i))
    _GUICtrlListBox_DeleteString($programmlistelinks, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlistelinks)
    EndIf
    EndFunc

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

    Func _cancel()
    $i=0
    If _GUICtrlListBox_GetText($programmlisterechts, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlisterechts, $i)=True Then
    _GUICtrlListBox_AddString($programmlistelinks, _GUICtrlListBox_GetText($programmlisterechts, $i))
    _GUICtrlListBox_DeleteString($programmlisterechts, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlisterechts)
    EndIf
    EndFunc

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

    ; #Die Funktion _cancelGesamt; genau andersrum wie auswahlGesamt()
    Func _cancelGesamt()
    _GUICtrlListBox_SetSel($programmlisterechts, -1)
    $i=0
    If _GUICtrlListBox_GetText($programmlisterechts, 0)<>"" Then
    Do
    If _GUICtrlListBox_GetSel($programmlisterechts, $i)=True Then
    _GUICtrlListBox_AddString($programmlistelinks, _GUICtrlListBox_GetText($programmlisterechts, $i))
    _GUICtrlListBox_DeleteString($programmlisterechts, $i)
    If $i>0 Then
    $i-=1
    EndIf
    Else
    $i+=1
    EndIf
    Until $i=_GUICtrlListBox_GetCount($programmlisterechts)
    EndIf
    EndFunc
    ; installieren
    Func _setup()
    If _GUICtrlListBox_GetCount($programmlisterechts)<>0 Then
    $s=0
    For $i = 0 To _GUICtrlListBox_GetCount($programmlisterechts)
    $programmSetup=_GUICtrlListBox_GetText($programmlisterechts, $i)
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < " & $programmSetup & " >")
    Run("D:\Setups\" & $programmSetup)
    ProcessWaitClose("autoinstall.exe")
    $s+=(100/_GUICtrlListBox_GetCount($programmlisterechts))
    GUICtrlSetData($progress, $s)
    Next
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < Installationsvorgang beendet >")
    Sleep(1500)
    _cancelGesamt()
    GUICtrlSetData($progressInformation, "Momentan wird installiert: < Derzeit läuft keine Installation >")
    GUICtrlSetData($progress, 0)
    Else
    MsgBox(64,"Message", "Keine Setups ausgewählt!")
    EndIf
    EndFunc

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

    Func _anzahlboxlinks()
    MsgBox(4160, "Information", "Anzahl: " & _GUICtrlListBox_GetCount($programmlistelinks))
    EndFunc

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

    Func _anzahlboxrechts()
    MsgBox(4160, "Information", "Anzahl: " & _GUICtrlListBox_GetCount($programmlisterechts))
    EndFunc
    ;PFADWINDOW---------------------------
    Func _pfadangabe()

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



    $pfad=GUICtrlCreateInput("D:\Setups", 10, 30)
    $knopf=GUICtrlCreateButton("Übernehmen", 100, 100)
    GUICtrlSetOnEvent($knopf, "_uebernehmen")

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

    EndFunc
    ;-------------------------------------
    Func _test()
    ;GUISetState(@GUI_CTRLId = $GUI_EVENT_CLOSE)
    MsgBox( 0, "E", "test erfolg")
    ;WinClose("test")
    EndFunc

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

    Func _beenden()
    Exit
    EndFunc

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

    Func _uebernehmen()
    $x=1
    GUISetState(@SW_SHOW, $mainWindow)
    _SetData()
    ;WinSetState("Installer", "", @SW_SHOW)
    GUISetState(@SW_HIDE, $pfadWIn)
    EndFunc

    [/autoit]
  • ich danke dir. Aber warum wird die 2. GUI gleich wieder beendet nach dem sie erscheint?
    ich bin erstmal weg.

    Gruß