telmob Posted November 17, 2012 Share Posted November 17, 2012 (edited) My main UI window is hanging and i can't find out why. I just want the script to do something after i close the window. So i open (show) the window and wait for it to be closed to apply settings, but after i show the window, i can't do anything with it, not even close it. Why? Case $t_msg = "Configure" WinSetState($SRPEGUI,"",@SW_SHOW) WinWaitClose("SRP Enforcer") $msg=msgbox(36,"Settings Changed","Activate now?") if $msg=6 then install("update") Edited November 17, 2012 by telmob Link to comment Share on other sites More sharing options...
JohnOne Posted November 17, 2012 Share Posted November 17, 2012 I think you need to show a little more code that you have. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 17, 2012 Developers Share Posted November 17, 2012 Does it get stuck on your winwaitclose? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
telmob Posted November 17, 2012 Author Share Posted November 17, 2012 (edited) I think you need to show a little more code that you have.My code is very simple, but kind of big. I have a GUI and a tray with several buttons. When i press 'Configure' in the Tray menu it opens the main window. So far so good, but then it hangs when waiting for it to close. It waits for the window to close to apply settings defined in the GUI.Does it get stuck on your winwaitclose?Yes, exactly. Edited November 17, 2012 by telmob Link to comment Share on other sites More sharing options...
Developers Jos Posted November 17, 2012 Developers Share Posted November 17, 2012 So, why are you using it then? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
telmob Posted November 17, 2012 Author Share Posted November 17, 2012 So, why are you using it then?Because it looks like the easy way to do it, ofcourse. What is the alternative? Link to comment Share on other sites More sharing options...
Developers Jos Posted November 17, 2012 Developers Share Posted November 17, 2012 Well, then you will have to explain what you want to do as i falling short in the clairvoyant department. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
telmob Posted November 17, 2012 Author Share Posted November 17, 2012 I already explained in the above post. Is there an alternative for WinWaitClose that doesn't hang my GUI? Link to comment Share on other sites More sharing options...
BrewManNH Posted November 17, 2012 Share Posted November 17, 2012 You really haven't explained it very well, you need to post some more of the code to allow us to figure out what you've done wrong. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
telmob Posted November 17, 2012 Author Share Posted November 17, 2012 You really haven't explained it very well, you need to post some more of the code to allow us to figure out what you've done wrong.Thats my problem, my code is sooo long and dispersed..... I'll try to organize a portion of the code so i can reproduce the error and i'll post it here after.Thank you Link to comment Share on other sites More sharing options...
JohnOne Posted November 17, 2012 Share Posted November 17, 2012 (edited) If that window ("SRP Enforcer") is your own gui, then you need to do things differently. If it is not, then you either have to remove that line or wait for the window to close. I can only assume the user is supposed to close it, otherwise I don't see the point of it. Edited November 17, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
telmob Posted November 18, 2012 Author Share Posted November 18, 2012 Yes, its my own gui. Sorry i haven't been able to post nothing very specific but i'm bashing my head against the wall with so many lines of code. I have a tray icon with a menu. The menu has an option to 'Configure'. When i press 'Configure' the main gui opens with some settings to chose from, and when i close the gui, the tray menu should update. So: Case $t_msg = "Configure" ; In case i press configure in the tray menu... GuiSetState(@SW_SHOW) ; ...the GUI shows Do Sleep(10) Until Not WinExists("SRP Enforcer") ; When the GUI is closed...... $msg=msgbox(36,"Settings Changed","Activate new settings now?") ; ....it shows this message. But i cannot close the GUI.......! Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 (edited) I am going to have to assume one last time that you have more than one gui and that this particular gui is not being polled by a message loop (GuiGetMsg) Without code to see, the best that can be offered is advice to look at the wiki where you will find Melba23's great guide on working with multiple gui's. Best of luck. Edited November 18, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
telmob Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) I am going to have to assume one last time that you have more than one guiand that this particular gui is not being polled by a message loop (GuiGetMsg)Without code to see, the best that can be offered is advice to look at the wikiwhere you will find Melba23's great guide on working with multiple gui's.Best of luck.I don't. I only have one GUI and the tray menu. Edited November 18, 2012 by telmob Link to comment Share on other sites More sharing options...
BrewManNH Posted November 18, 2012 Share Posted November 18, 2012 How do you plan on closing the gui if you don't look for the exit message from it? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
telmob Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) I'm sorry, i don't understand. What do you mean? The GUI has an exit button and even a 'minimize to tray' (@SW_HIDE)button, and they work (without the winwaitclose or whatever). Edited November 18, 2012 by telmob Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 You really are intent on learning the hard way, at least you're consistent. Anyone else who posted a reproducer code would have had this problem fixed within 5 minutes. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 18, 2012 Share Posted November 18, 2012 I'm sorry, i don't understand. What do you mean?The GUI has an exit button and even a 'minimize to tray' (@SW_HIDE)button, and they work (without the winwaitclose or whatever).Where does the script check for the exit condition on the GUI? Because you're not checking in the Do loop, so it will never close, unless you're using OnEvent mode, which it doesn't appear that you are. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted November 18, 2012 Developers Share Posted November 18, 2012 (edited) With Event mode you need to ensure that the Fired Func isn't hanging either or else the next event will not fire until it completes. There are a couple of options: 1 setting a variable in the Fired Event Func and returning and then act in the Variable value in the While-Wend loop. 2.do a mix of Event and Message loop. This is an example of the second option: expandcollapse popup#include <GUIConstantsEx.au3> Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Wait for window", 10, 30, 100) $Button_2 = GUICtrlCreateButton("Close", 0, -1) GUICtrlSetOnEvent(-1, "ClosePressed") GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $Button_2 MsgBox(0, "MsgLoop-Close Pressed","MsgLoop-Close Pressed") ExitLoop Case $msg = $Button_1 Opt("GUIOnEventMode", 1) GUICtrlSetData($Button_1,"Waiting-hang") Winwait("does exixts") ; hanging func GUICtrlSetData($Button_1,"Wait for window") Opt("GUIOnEventMode", 0) EndSelect WEnd EndFunc ;==>Example ; Func ClosePressed() MsgBox(0, "Event - Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) Exit EndFunc ;==>CancelPressed ; Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox(0, "Event-Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit EndSelect EndFunc ;==>SpecialEvents Edited November 18, 2012 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
telmob Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) Where does the script check for the exit condition on the GUI? Because you're not checking in the Do loop, so it will never close, unless you're using OnEvent mode, which it doesn't appear that you are. I now understand. It is clear to me now that i should place the 'after-exit' settings in the gui itself instruction after closing it. With Event mode you need to ensure that the Fired Func isn't hanging either or else the next event will not fire until it completes. There are a couple of options: 1 setting a variable in the Fired Event Func and returning and then act in the Variable value in the While-Wend loop. 2.do a mix of Event and Message loop. This is an example of the second option: expandcollapse popup#include <GUIConstantsEx.au3> Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Wait for window", 10, 30, 100) $Button_2 = GUICtrlCreateButton("Close", 0, -1) GUICtrlSetOnEvent(-1, "ClosePressed") GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $Button_2 MsgBox(0, "MsgLoop-Close Pressed","MsgLoop-Close Pressed") ExitLoop Case $msg = $Button_1 Opt("GUIOnEventMode", 1) GUICtrlSetData($Button_1,"Waiting-hang") Winwait("does exixts") ; hanging func GUICtrlSetData($Button_1,"Wait for window") Opt("GUIOnEventMode", 0) EndSelect WEnd EndFunc ;==>Example ; Func ClosePressed() MsgBox(0, "Event - Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) Exit EndFunc ;==>CancelPressed ; Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox(0, "Event-Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit EndSelect EndFunc ;==>SpecialEvents Thank you so much for your help and time spent. I have solved my problem. It was indeed a placement problem. Sorry i couldn't explain any better, but i already have 7000 lines of code and some of it i took from two scripts i found here on the forum, so it was hard for me to extract the portion i was having trouble with. Again... thank you and sorry for the trouble. You guys rock! Edited November 18, 2012 by telmob 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