ucsAdmin Posted August 26, 2008 Share Posted August 26, 2008 Hello First of all, congratulation to AutoIt team !!!!! Such a great work ! In a window (called 1st level) I need to create a second window (called 2nd level) by a button event (first event) then set several controls datas in it then show this window then wait this window to be closed by a button event (second event) then retrieve informations from controls in the 2nd level window to use it in first level I need to use event mode the problem is : in the first fired event, it seems impossible to fire an other event (need confirmation) so a loop in this event won't work to work I guess it is necessary to go out of the first event Below is the code I used to show the problem and the one to make it work My question is : is there a simpler way to do it ? cause it will be a bit heavy to code. Thanks for replies expandcollapse popup;This sample doesn't work #################################################################################################### ######################################## #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $First_level_window = GUICreate("First level window", 300, 100, 100,100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton1 = GUICtrlCreateButton("Open 2nd level window", 70, 50, 200) GUICtrlSetOnEvent($okbutton1, "OKButton1") GUISetState(@SW_SHOW) $Open_second_level_window = False While 1 sleep(1000) ; Idle around WEnd Func OKButton1() ; It doesn't work : Open_second_level_window() EndFunc Func Open_second_level_window() $Second_level_window = GUICreate("Second level window ", 200, 100,300,300) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlCreateLabel("It doesn't work", 30, 10) $okbutton2 = GUICtrlCreateButton("Open msgbox", 70, 50, 80) GUICtrlSetOnEvent($okbutton2, "OKButton2") GUISwitch($Second_level_window) ; important stuff to do here !!!!!!!!!!! GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd ; important stuff to do here !!!!!!!!!!! EndFunc Func OKButton2() msgBox(0, "GUI Event", "It works!") EndFunc Func CLOSEClicked() MsgBox(0, "GUI Event", "You clicked CLOSE ! Exiting...") Exit EndFunc ;~; This sample works #################################################################################################### ######################################## ;~ #include <GUIConstantsEx.au3> ;~ Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ;~ $First_level_window = GUICreate("First level window", 300, 100, 100,100) ;~ GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;~ $okbutton1 = GUICtrlCreateButton("Open 2nd level window", 70, 50, 200) ;~ GUICtrlSetOnEvent($okbutton1, "OKButton1") ;~ GUISetState(@SW_SHOW) ;~ $Open_second_level_window = False ;~ While 1 ;~ sleep(1000) ; Idle around ;~ If $Open_second_level_window = True Then ;~ $Open_second_level_window = False ;~ Open_second_level_window() ;~ EndIf ;~ WEnd ;~ Func OKButton1() ;~ ; It works : ;~ $Open_second_level_window = true ;~ EndFunc ;~ Func Open_second_level_window() ;~ $Second_level_window = GUICreate("Second level window ", 200, 100,300,300) ;~ GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;~ GUICtrlCreateLabel("It doesn't work", 30, 10) ;~ $okbutton2 = GUICtrlCreateButton("Open msgbox", 70, 50, 80) ;~ GUICtrlSetOnEvent($okbutton2, "OKButton2") ;~ GUISwitch($Second_level_window) ;~ ; important stuff to do here !!!!!!!!!!! ;~ GUISetState(@SW_SHOW) ;~ While 1 ;~ Sleep(1000) ; Idle around ;~ WEnd ;~ ; important stuff to do here !!!!!!!!!!! ;~ EndFunc ;~ Func OKButton2() ;~ msgBox(0, "GUI Event", "It works!") ;~ EndFunc ;~ Func CLOSEClicked() ;~ MsgBox(0, "GUI Event", "You clicked CLOSE ! Exiting...") ;~ Exit ;~ EndFunc Link to comment Share on other sites More sharing options...
martin Posted August 26, 2008 Share Posted August 26, 2008 No simpler way that I know, but your conclusions about the nature of the problem and your solution are correct IMO. Welcome to the AutoIt forums ucsAdmin!! Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ucsAdmin Posted August 27, 2008 Author Share Posted August 27, 2008 I found an other and much better solution in ArrayEdt script. Thanks to the contributor for it !!!! It's really great ! I don't know if it's not bad to switch between message and event mode but it works fine Hope it will help somebody. It helps me expandcollapse popup; This sample works #################################################################################################### ######################################## #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $First_level_window = GUICreate("First level window", 300, 100, 100,100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton1 = GUICtrlCreateButton("Open 2nd level window", 70, 50, 200) GUICtrlSetOnEvent($okbutton1, "OKButton1") GUISetState(@SW_SHOW) $Second_level_window = GUICreate("Second level window ", 200, 100,300,300) GUICtrlCreateLabel("It works", 30, 10) $okbutton2 = GUICtrlCreateButton("Open msgbox", 70, 50, 80) While 1 sleep(100) ; Idle around WEnd Func OKButton1() Open_second_level_window() EndFunc Func Open_second_level_window() Local $oldGuiOnEventMode ; important stuff to do here !!!!!!!!!!! $oldGuiOnEventMode = AutoItSetOption('GuiOnEventMode',0) GUISwitch($Second_level_window) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case 0 ContinueLoop Case $okbutton2 OKButton2() GUISetState(@SW_HIDE) ExitLoop EndSwitch Sleep(20) ; Idle around WEnd ; important stuff to do here !!!!!!!!!!! AutoItSetOption('GuiOnEventMode',$oldGuiOnEventMode) EndFunc Func OKButton2() msgBox(0, "GUI Event", "It works!") EndFunc Func CLOSEClicked() MsgBox(0, "GUI Event", "You clicked CLOSE ! Exiting...") Exit EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now