Grüßt euch erstmal,
ich hab hier ein Skript was erstmal nichts spannendes macht außer 2 GUIs anzuzeigen. Jetzt habe ich das Problem, dass wenn ich in Zeile 51 ankomme, er sofort nachdem er mit gui2() durch ist, die nachfolgenden Befehle abarbeitet, also hier die MessageBox. Mal angenommen ich möchte mein gui2() solange pausieren, bis es geschlossen wird, aber trotzdem die Möglichkeit haben, meine registrierten Funktionen in gui2 zu benutzen und das danach (nachdem gui2 geschlossen wurde) erst die MessageBox und nachfolgende Befehle ausgeführt werden. Wie könnte man das realisieren?
[autoit]#include <GUIConstantsEx.au3>
[/autoit][autoit][/autoit][autoit]Opt("GUIOnEventMode", 1)
[/autoit][autoit][/autoit][autoit]Global $hGUI1, $hGUI2 = 9999, $hButton1, $hButton2, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements
[/autoit][autoit][/autoit][autoit]gui1()
[/autoit][autoit][/autoit][autoit]Func gui1()
$hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUISetState()
While 1
Sleep(10)
WEnd
EndFunc ;==>gui1
Func gui2()
$hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350, -1, -1, $hGUI1)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUISetState()
;~ While 1
;~ Sleep(10)
;~ WEnd
EndFunc ;==>gui2
Func On_Close()
Switch @GUI_WINHANDLE ; See which GUI sent the CLOSE message
Case $hGUI1
Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<<
Case $hGUI2
GUIDelete($hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
GUICtrlSetState($hButton2, $GUI_ENABLE)
EndSwitch
EndFunc
Func On_Button()
Switch @GUI_CTRLID ; See which button sent the message
Case $hButton1
MessageBox(1) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
Case $hButton2
GUICtrlSetState($hButton2, $GUI_DISABLE)
gui2()
; hier pausieren, bis gui2() geschlossen wurde, aber es muss möglich sein die registrierten Funktionen in gui2 zu benutzen
;~ While 1
;~ Sleep(10)
;~ WEnd
MsgBox(0, "sfdsf", "sdfsfd") ; hier weiter machen, nachdem gui2 nicht mehr benötigt wird (geschlossen wurde)
Case $hButton3
MessageBox(2) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<<
EndSwitch
EndFunc
Func MessageBox($iIndex)
MsgBox("", "MsgBox " & $iIndex, "Test from Gui " & $iIndex)
EndFunc