DavidFC3S Posted January 3, 2011 Share Posted January 3, 2011 Hi Guys, I'm very new to coding in general. I've been playing with AutoIt for a few days now and made quite a few interesting scripts that make my life at work a hell of a lot easier. So this morning I decided to try and teach myself GUI. I've made a few single window GUI scripts that work great but when I tried to delve into child windows it all went pear shaped. I know there is a child window example that comes with AutoIt and using that as an example I can open a parent and child window then close them both one at a time, however when I make a parent window with a button, then make that button open a child window I get completely lost. I have managed to work out how to close the child window without closing the parent, but when I close the child the parent loses all functionality and nothing works on it any more. I'm sure there are scripts already out there I could copy and paste from but I would prefer to learn how to do it myself. As such I created the below code to simply open a child to show you what I mean. I'm assuming that after the child closes it's not returning to the correct point in the loop waiting for input on the parent form? But not sure how to correct that. Any guidance would be greatly appreciated. #include <GuiConstantsEx.au3> Global $ParentWin = GUICreate("Parent Window",210,50) $TestButton = GUICtrlCreateButton("Create Child",70,10) GUISetState() While 1 $TestLoop = GUIGetMsg() Switch $TestLoop Case $TestButton $TestChild = GUICreate("Child Window", 210, 50, 533, 432) GUISetState(1) While 1 $TestWindow = GUIGetMsg(1) Select Case $TestWindow[0] = $GUI_EVENT_CLOSE If $TestWindow[1] = $TestChild Then GUIDelete($TestChild) EndIf EndSelect WEnd EndSwitch WEnd Link to comment Share on other sites More sharing options...
DavidFC3S Posted January 3, 2011 Author Share Posted January 3, 2011 (edited) A few tips. 1. If you haven't already, install SciTE4AutoIt3.exe from this page. 2. Use Tidy to clean up your code. Press Ctrl+T or select Tidy AutoIt Source from the Tools menu in SciTE 3. Use code tags when posting on the forums. Remove the spaces between these brackets. [ code='autoit']Code goes here[/code ]. 4. Your assumption is correct. You need an Exitloop in your Child GUI's loop to send the script back to the Parent GUI's loop. You should also be checking for close messages in the main Parent GUI's loop. Here is the corrected code. Thank you so much, I knew I had to be close. Thanks for replying so quickly too I am using SciTE4 to write the code, it just came out that way when I copied and pasted to the forum. I didn't know about the code tags but I'll use them next time sorry Edited January 3, 2011 by DavidFC3S Link to comment Share on other sites More sharing options...
DavidFC3S Posted January 3, 2011 Author Share Posted January 3, 2011 4. Your assumption is correct. You need an Exitloop in your Child GUI's loop to send the script back to the Parent GUI's loop. You should also be checking for close messages in the main Parent GUI's loop.I do this in my actual scripts, the one I pasted on the form I quickly wrote to demonstrate the exact problem I was having. Thanks for the tip though I'll remember to add it to everything script from now on Link to comment Share on other sites More sharing options...
Razormaul Posted July 20, 2016 Share Posted July 20, 2016 On 3.1.2011 at 7:20 AM, DavidFC3S said: The corrected code? Im sorry but i do not see it? Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty! Link to comment Share on other sites More sharing options...
BrewManNH Posted July 20, 2016 Share Posted July 20, 2016 2 hours ago, Razormaul said: The corrected code? Im sorry but i do not see it? And you probably never will, neither user has been here in over 5 years so it's highly doubtful they'll respond any time soon.. 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...
Razormaul Posted July 22, 2016 Share Posted July 22, 2016 On 20.7.2016 at 5:11 PM, BrewManNH said: And you probably never will, neither user has been here in over 5 years so it's highly doubtful they'll respond any time soon.. Hehe, true.. Found the one Melba23 made.. Im good. Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty! 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