KennethWalle Posted February 13, 2015 Share Posted February 13, 2015 Hi. When i have multiple gui, how do i force close the old gui when open a new? #include Global $hButton3 = 9999 gui1() Func gui1() $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100) $hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) $hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 MsgBox("", "MsgBox 1", "Test from Gui 1") Case $hButton2 GUICtrlSetState($hButton2, $GUI_DISABLE) gui2() Case $hButton3 MsgBox("", "MsgBox 2", "Test from Gui 2") EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350) $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() EndFunc ;==>gui2 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 13, 2015 Moderators Share Posted February 13, 2015 There is a page on the Wiki that should be of assistance: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
kylomas Posted February 14, 2015 Share Posted February 14, 2015 KW, It looks like you took the code you posted directly out of the Wiki that JL pointed you to. Did you read the entire article? If so, what do you not understand? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
KennethWalle Posted February 14, 2015 Author Share Posted February 14, 2015 KW, It looks like you took the code you posted directly out of the Wiki that JL pointed you to. Did you read the entire article? If so, what do you not understand? kylomas Yes i actually did, if you test the code, you will see when you open the 2nd gui, "gui1" doesnt close. That is what i want. So in the project im currently working on, i have alote more than 2 gui. Kinda anoying haveing 100 of windows open. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2015 Moderators Share Posted February 14, 2015 when you open the 2nd gui, "gui1" doesnt close. That is what i wantSo simply add the code to close it. #include <GUIConstantsEx.au3> Global $hButton3 = 9999 gui1() Func gui1() $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100) $hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) $hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 MsgBox("", "MsgBox 1", "Test from Gui 1") Case $hButton2 GUIDelete($hGUI1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< gui2() Case $hButton3 MsgBox("", "MsgBox 2", "Test from Gui 2") EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350) $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() EndFunc ;==>gui2M23 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...
KennethWalle Posted February 14, 2015 Author Share Posted February 14, 2015 So simply add the code to close it. #include <GUIConstantsEx.au3> Global $hButton3 = 9999 gui1() Func gui1() $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100) $hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) $hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 MsgBox("", "MsgBox 1", "Test from Gui 1") Case $hButton2 GUIDelete($hGUI1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< gui2() Case $hButton3 MsgBox("", "MsgBox 2", "Test from Gui 2") EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350) $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() EndFunc ;==>gui2 M23 Awesome, thanks. it worked Link to comment Share on other sites More sharing options...
kylomas Posted February 14, 2015 Share Posted February 14, 2015 100 windows??? Give us the elevator version of what you are doing and maybe you will get some alternative ideas. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
KennethWalle Posted February 14, 2015 Author Share Posted February 14, 2015 100 windows??? Give us the elevator version of what you are doing and maybe you will get some alternative ideas. yeah that was just a random number as you would use it back and forth. What im working on is an poker push/fold strategy Nearly finish thou, but theres still some anoying bugs. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2015 Moderators Share Posted February 14, 2015 KennethWalle, What im working on is an poker push/fold strategyYou might not have read the Forum rules since your arrival. Please do read them - particularly the bit about not discussing game automation - before you post again. 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...
KennethWalle Posted February 14, 2015 Author Share Posted February 14, 2015 KennethWalle, You might not have read the Forum rules since your arrival. Please do read them - particularly the bit about not discussing game automation - before you post again. M23 Sorry, ill shut it in my defence, i havent posted anything regarding my script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2015 Moderators Share Posted February 14, 2015 (edited) KennethWalle,Indeed you have not, which is why you got a friendly warning and nothing more. M23 Edited February 14, 2015 by Melba23 Typo KennethWalle 1 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...
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