So i tried using GuiOnEventMode, but when i made the SecondGui the buttons wouldn't respond.
Is it like the functions can't be called since its in a function or am i doing something wrong ?
AutoIt
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $State = 0 $Gui = GUICreate("Main gui", 150, 60) $Button1 = GUICtrlCreateButton("Open", 10, 10, 60, 40) $Button2 = GUICtrlCreateButton("Exit", 80, 10, 60, 40) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseMain") GUICtrlSetOnEvent($Button1, "SecondGui") GUICtrlSetOnEvent($Button2, "CloseMain") Func CloseMain() Exit EndFunc ;==>CloseMain Func CloseSecond() $State = 1 EndFunc ;==>CloseSecond Func Msg() MsgBox("", "", "A BOX!") EndFunc ;==>Msg Func SecondGui() $SecondGui = GUICreate("Second gui", 150, 60) $ButtonMsg = GUICtrlCreateButton("Msg", 10, 10, 60, 40) $ButtonClose = GUICtrlCreateButton("Close", 80, 10, 60, 40) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseSecond") GUICtrlSetOnEvent($Button1, "Msg") GUICtrlSetOnEvent($Button2, "CloseSecond") While $State = 0 Sleep(40) WEnd EndFunc ;==>SecondGui While 1 Sleep(40) WEnd