Syntaxe Posted April 30, 2008 Share Posted April 30, 2008 When you run this script, you will get a window, then click a button, then another window. When you close the second window (win2) the the first one (win1) closes as well, how can I get win1 keep running? #include <GUIConstants.au3> $win1 = GUICreate("Form1", 436, 96, 193, 125) $win1Button1 = GUICtrlCreateButton("Click meh!", 40, 16, 353, 57, 0) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $win1Button1 #include <GUIConstants.au3> $win2 = GUICreate("win2", 330, 225, 193, 125) $win2Label1 = GUICtrlCreateLabel("a new window!", 88, 16, 131, 27) GUICtrlSetFont(-1, 14, 400, 0, "Tahoma") $win2Label2 = GUICtrlCreateLabel("=)", 96, 40, 111, 120) GUICtrlSetFont(-1, 72, 400, 0, "Tahoma") $win2Label3 = GUICtrlCreateLabel("now close meh :S", 64, 184, 170, 29) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndSwitch WEnd Link to comment Share on other sites More sharing options...
newbiescripter Posted April 30, 2008 Share Posted April 30, 2008 You could use GUIDelete Regards Link to comment Share on other sites More sharing options...
James Posted April 30, 2008 Share Posted April 30, 2008 Remember, you only need to include GUIConstants.au3 once Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Syntaxe Posted April 30, 2008 Author Share Posted April 30, 2008 You could use GUIDeleteThanks! Works fine, thanks Remember, you only need to include GUIConstants.au3 onceYeah, I was abit lazy in that, was a quick making Thanks guys, quick answer Link to comment Share on other sites More sharing options...
cppman Posted April 30, 2008 Share Posted April 30, 2008 (edited) EDIT: Didn't see the above reply.expandcollapse popup#include <GUIConstants.au3> $win1 = GUICreate("Form1", 436, 96, 193, 125) $win1Button1 = GUICtrlCreateButton("Click meh!", 40, 16, 353, 57, 0) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $win1Button1 $win2 = GUICreate("win2", 330, 225, 193, 125) $win2Label1 = GUICtrlCreateLabel("a new window!", 88, 16, 131, 27) GUICtrlSetFont(-1, 14, 400, 0, "Tahoma") $win2Label2 = GUICtrlCreateLabel("=)", 96, 40, 111, 120) GUICtrlSetFont(-1, 72, 400, 0, "Tahoma") $win2Label3 = GUICtrlCreateLabel("now close meh :S", 64, 184, 170, 29) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) GUISwitch($win2) While 1 $nMsg2 = GUIGetMsg() Switch $nMsg2 Case $GUI_EVENT_CLOSE GUIDelete($win2) GUISwitch($win1) ExitLoop EndSwitch WEnd EndSwitch WEnd Edited April 30, 2008 by cppman Miva OS Project Link to comment Share on other sites More sharing options...
Syntaxe Posted April 30, 2008 Author Share Posted April 30, 2008 Thanks! Nice Happy codin! Link to comment Share on other sites More sharing options...
newbiescripter Posted April 30, 2008 Share Posted April 30, 2008 Nice with the GUISwitch($win1) I usely set the new GUI in a function and then use return like this: Don't what is best? expandcollapse popup#include <GUIConstants.au3> $win1 = GUICreate("Form1", 436, 96, 193, 125) $win1Button1 = GUICtrlCreateButton("Click meh!", 40, 16, 353, 57, 0) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $win1Button1 _window2() EndSwitch WEnd Func _window2() $win2 = GUICreate("win2", 330, 225, 193, 125) $win2Label1 = GUICtrlCreateLabel("a new window!", 88, 16, 131, 27) GUICtrlSetFont(-1, 14, 400, 0, "Tahoma") $win2Label2 = GUICtrlCreateLabel("=)", 96, 40, 111, 120) GUICtrlSetFont(-1, 72, 400, 0, "Tahoma") $win2Label3 = GUICtrlCreateLabel("now close meh :S", 64, 184, 170, 29) GUICtrlSetFont(-1, 16, 400, 0, "Tahoma") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($win2) Return EndSwitch WEnd EndFunc Regards Link to comment Share on other sites More sharing options...
cppman Posted April 30, 2008 Share Posted April 30, 2008 Actually, yours is probably more correct (But you should use a different variable for messages, other than $nMsg). Miva OS Project Link to comment Share on other sites More sharing options...
Syntaxe Posted April 30, 2008 Author Share Posted April 30, 2008 That wasnt so bad, it was actually a really good solution. Then you get more control over the mainframe. Since you dont got the While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $win1Button1 ; Forever with code EndSwitch WEnd so if more buttons, notify stuff or what ever you guys call it, then I whould go for that func solution Link to comment Share on other sites More sharing options...
GEOSoft Posted April 30, 2008 Share Posted April 30, 2008 so if more buttons, notify stuff or what ever you guys call it, then I whould go for that func solution Yes, Also look in the help file for GUISwitch() 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...
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