DenDuze Posted December 2, 2010 Share Posted December 2, 2010 Hello, I'm a new user of AutoIt and I have the following problem: - have a au3-script that does some processing (getting some values and check a few items - when everything is OK I call a function (that exist in a included au3-script) - that function creates a GUI, that GUI works with then 'Opt("GUIOnEventMode", 1)' - In that included-file there are only functions that process the user-events - Now is my problem that when they click OK (or they close the GUI) I want to return processing my original script (all the lines after the GUI-create) so I want to close this GUI window but I'm probably doing something wrong. Simplified I have the following Master Script: #include <file2.au3> <multiple checks> if <all checks are ok> then func-CreateWindow() msgbox(......) file2.au3 Opt("MustDeclareVars", 1) func func-CreateWindow() .... $Screen = GUICreate("Generate", 400, 150) GUISetOnEvent($GUI_EVENT_CLOSE, "Func-CloseThisWindow") EnvSet("BSCREEN",$Screen) ... while 1 Sleep(1000) ; Idle WEnd EndFunc func func-CloseThisWindow() local $Screen $screen = EnvGet("BSCREEN") winclose($Screen) EndFunc Now when I click the window-close button the GUI-screen stays vissible and I don't get the MsgBox that is coded just after the func-CreateWindow (in my masterscript) I've tried multiple variations to do this but always the same result. The only thing that works is to use a Exit-statement but then my main program also stops and that's not the wanted behaviour What I'm I doing wrong? Note: I will change the whole setup (first create my window - then I will do my tests and if something is not Ok I will stop the program (with exit because that works ok). But I still like to know what's my problem with my first method. Thanks Didier Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 2, 2010 Moderators Share Posted December 2, 2010 DenDuze,Welcome to the AutoIt forum. A novel way of coding, if I may say so. Your problem arises because you have no way of escaping from the While...WEnd loop in file2.au3. In keeping with the coding style you are using, I would suggest something along these lines (look for the <<<<<<<<<<<<<<<<<<<< lines:Func CreateWindow() $Screen = GUICreate("Generate", 400, 150) EnvSet("BSCREEN",$Screen) EnvSet("GUIEXIT", 0) ; Create an envvar to keep us in the loop <<<<<<<<<<<<<<<<<<<< GUISetOnEvent($GUI_EVENT_CLOSE, "CloseThisWindow") GUISetState() While EnvGet("GUIEXIT") = 0 ; Check the envvar <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Sleep(1000) ; Idle WEnd EndFunc ;==>CreateWindow Func CloseThisWindow() $Screen = EnvGet("BSCREEN") GUIDelete($Screen) ; Better to use this as you created it <<<<<<<<<<<<<<<<<<<<<<<<< EnvSet("GUIEXIT", 1) ; Set the envvar to exit the loop <<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc ;==>CloseThisWindowI get back to the calling script with no problems now. Note that the function names you were using are invalid - from the Help file: "Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores"M23P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. 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...
DenDuze Posted December 13, 2010 Author Share Posted December 13, 2010 @Melba23: thanks for your answer Whats so novel on this code? For the function-names: In our company we have some naming-conventions and I'm only applying these rules also in this script (so it is the same as all out other coding) I will keep in mind the info about the autoit-tags Regards Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 13, 2010 Moderators Share Posted December 13, 2010 DenDuze,I used the word "novel" because I would have expected the code you have put into an #include file to be a simple function within the main script. There is nothing wrong with doing it your way - it is just that I have not seen it before. Why do you do it this way? Is it to reduce the size of the main script when editing? 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...
GEOSoft Posted December 13, 2010 Share Posted December 13, 2010 You would really love the way Project Express is written then. It would drive you over the edge I'm afraid. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 13, 2010 Moderators Share Posted December 13, 2010 George, I think I am already over it - or at least it feels like that sometimes! 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...
GEOSoft Posted December 13, 2010 Share Posted December 13, 2010 I think I am already over itM23I concur George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
hg2051 Posted March 13, 2013 Share Posted March 13, 2013 At least when wanting to kill Ecel 2007, "WinKill" works only if followed by "ProcessClose" hzw 1 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