TheBreeder Posted December 31, 2009 Share Posted December 31, 2009 I open 2 windows and open a third when a button is pressed. The OnEvent for $GUI_CLOSE_EVENT is no longer working when the third window is open. It works fine when the first two windows are open. But once the thirs is opend, the event is no longer executed. <#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> ;Global $Form2_1, $Form3_1, Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $Form1 = GUICreate("Form1", 633, 447, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Button1 = GUICtrlCreateButton("Button1", 24, 24, 89, 25, 0) GUICtrlSetOnEvent(-1, "Button1") GUISetState() $Form2_1 = GUICreate("Form2", 633, 447, 193, 125, BitOR($WS_OVERLAPPEDWINDOW, $WS_DLGFRAME), $WS_EX_MDICHILD, $Form1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE2Clicked") GUISetState() While 1 Sleep(2000) WEnd Exit Func _third() $Form3_1 = GUICreate("Form3", 633, 447, 307, 143, $ws_TILEDWINDOW, $WS_EX_MDICHILD, $Form1) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE3Clicked") While 1 Sleep(2000) WEnd EndFunc ;==>_third Func button1() _third() EndFunc ;==>button1 Func closeclicked() Exit EndFunc ;==>closeclicked Func close2clicked() MsgBox(0, "", "Colse2 clicked") EndFunc ;==>close2clicked Func close3clicked() MsgBox(0, "", "Close 3 clicked") EndFunc ;==>close3clicked > Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 31, 2009 Share Posted December 31, 2009 Events are queued and executed in order, so when you lock him in that loop you fuck up all chances of working on more events. You must remove the loop in _third() and let him go back to the main-loop. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2009 Moderators Share Posted December 31, 2009 Richardr,Remove the While...WEnd loop from your _third() function. The script will not run another function until that one ends and the eternal loop you have set up means that it never will! Two other points:1. You only need a Sleep(10) in While...WEnd loops in OnEvent mode - you have to wait for the Sleep to finish before the script continues, so making the Sleep longer than you have to just makes the script unresponsive.2. If you post code, please use Code tags - it makes it much easier to read. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here).M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 31, 2009 Share Posted December 31, 2009 1. You only need a Sleep(10) in While...WEnd loops in OnEvent mode - you have to wait for the Sleep to finish before the script continues, so making the Sleep longer than you have to just makes the script unresponsive.You're thinking about MessageLoop Mode now To clarify, open up the example for GUISetOnEvent and set the loop to 999999 or something, and the events will still be instantenous .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2009 Moderators Share Posted December 31, 2009 AdmiralAlkex, In my defence, I use OnEvent mode so rarely that at my advanced age I can never remember what exactly goes on... Happy New Year! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TheBreeder Posted December 31, 2009 Author Share Posted December 31, 2009 Thanks for qour quick response. Happy Newyear everybody :-) Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos. Link to comment Share on other sites More sharing options...
willichan Posted January 18, 2010 Share Posted January 18, 2010 (edited) I should have looked here sooner. I bashed my head on this problem for two weeks. Although, on the bright side, I threw an entire module out and rewrote from scratch in the process, and came out cleaner in the end. The "double loops" was what was killing the script (and I only had two windows). I will have to rethink the way I write my modules that contain GUIs. I can't help but wonder if this is a change in AutoIt's behavior. Other events, like maximize and minimize, still work through the double loops. Only close is not working, and I don't recall any of my other scripts having this issue. Edited January 18, 2010 by willichan My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash 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