zetaimmersion Posted March 18, 2017 Share Posted March 18, 2017 i am creating 1 main gui and using 2 buttons i would like to create a 2'nd gui (which works fine). Is just i cannot close the subsequent gui windows and i don't know why expandcollapse popup#include <GUIConstantsEx.au3> Global $gui_dummy = 9999 ; declare dummy gui variables main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable button wonce pressed add_func () Case $del_bttn GUICtrlSetState($del_bttn, $GUI_DISABLE) delete_func () Case $close_bttn ExitLoop EndSwitch Case $gui_dummy Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE GUIDelete($gui_dummy) GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed GUICtrlSetState($del_bttn, $GUI_ENABLE) EndSwitch EndSwitch WEnd EndFunc Func delete_func () ; GUI size for the window $delete_gui = GUICreate("Deletion GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 30,40) $number_delete = GUICtrlCreateInput("", 30, 60, 90) $RUN_delete = GUICtrlCreateButton("Delete action", 210, 225) $RUN_close = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $RUN_close ExitLoop Case $RUN_delete ; do other fucntions or checks and/or buttons EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_gui = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $RUN_add = GUICtrlCreateButton("Delete action", 210, 225) $RUN_close = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $RUN_close ExitLoop Case $RUN_add ; do other fucntions or checks and/or buttons EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 18, 2017 Moderators Share Posted March 18, 2017 zetaimmersion, Welcome to the AutoIt forums. You only need one GUIGetMsg loop - like this: expandcollapse popup#include <GUIConstantsEx.au3> Global $add_GUI = 9999, $RUN_close = 9999 ; declare dummy gui variables main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUICtrlSetState($del_bttn, $GUI_DISABLE) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_bttn ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable button once pressed GUICtrlSetState($del_bttn, $GUI_ENABLE) add_func () Case $del_bttn GUIDelete($add_GUI) GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed GUICtrlSetState($del_bttn, $GUI_DISABLE) EndSwitch Case $add_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $RUN_close GUIDelete($add_GUI) GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed GUICtrlSetState($del_bttn, $GUI_DISABLE) EndSwitch EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_GUI = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $RUN_add = GUICtrlCreateButton("Delete action", 210, 225) $RUN_close = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Please ask if you have any questions about the script. 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...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 Thank you for having me Melba23 previously i did have it run your way as a v0.1 with only 1 action but in my case i have it expanded to something as follows: 1. main window - separate add button and separate delete button 2. depending which button is selected then 2.a add - it perform adding to the ActiveDirectory and other scripts with a predefined form and questions 2.b delete - it performs other sets of questions and deletes ActiveDirectory entries and other things If i can get this working, the modularity of it would allow me to add other automation via another buttons as the script evolves Link to comment Share on other sites More sharing options...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 Think i got something going by changing a few things in the script Thank you Melba23, this is what i wanted. Appreciate the help. expandcollapse popup#include <GUIConstantsEx.au3> Global $add_GUI = 9999, $RUN_close = 9999 ; declare dummy gui variables main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUICtrlSetState($del_bttn, $GUI_ENABLE) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_bttn ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable buttons once 2nd gui is opeed GUICtrlSetState($del_bttn, $GUI_DISABLE) add_func () Case $del_bttn GUIDelete($add_GUI) GUICtrlSetState($add_bttn, $GUI_DISABLE) ;disable buttons once 2nd gui is opeed GUICtrlSetState($del_bttn, $GUI_DISABLE) delete_func () EndSwitch Case $add_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $RUN_close GUIDelete($add_GUI) GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed GUICtrlSetState($del_bttn, $GUI_ENABLE) EndSwitch EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_GUI = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $RUN_add = GUICtrlCreateButton("Delete action", 210, 225) $RUN_close = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Func delete_func () ; GUI size for the window $add_GUI = GUICreate("Delete GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $RUN_add = GUICtrlCreateButton("Add action", 210, 225) $RUN_close = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 18, 2017 Moderators Share Posted March 18, 2017 (edited) zetaimmersion, Based on what you actually wanted, I came up with this: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $add_GUI = 9999, $del_GUI = 9999 Global $add_add = 9999, $close_add = 9999 Global $del_del = 9999, $close_del = 9999 main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_bttn ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable button once pressed add_func () Case $del_bttn GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed del_func() EndSwitch Case $add_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_add GUIDelete($add_GUI) $add_add = 9999 $close_add = 9999 GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $add_add MsgBox($MB_SYSTEMMODAL, "Adding", "Add action button pressed") EndSwitch Case $del_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_del GUIDelete($del_GUI) $del_del = 9999 $close_del = 9999 GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $del_del MsgBox($MB_SYSTEMMODAL, "Deleting", "Delete action button pressed") EndSwitch EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_GUI = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $add_add = GUICtrlCreateButton("Add action", 210, 225) $close_add = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Func del_func () ; GUI size for the window $del_GUI = GUICreate("Delete GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_del = GUICtrlCreateInput("", 130, 160, 90) $del_del = GUICtrlCreateButton("Delete action", 210, 225) $close_del = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc M23 Edit: I see you already have a solution - see how it compares! Edited March 18, 2017 by Melba23 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...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 next beer is on me man! this is exactly what i wanted. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 18, 2017 Moderators Share Posted March 18, 2017 zetaimmersion, Delighted to hear it. 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...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 once I open the 2nd gui and click on the add or delete action button, how do i pipe the input box details to the msg box? previously it was easyer as the ctrlread was in the same place as the current guigetmsg for example at the Case $add_add how do i read GUICtrlRead($number_add) from the add_func such that MsgBox($MB_SYSTEMMODAL, "Adding", "Add action button pressed") includes the user's input details from the input box? Link to comment Share on other sites More sharing options...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 for example, the return is 0 and although i know why that is i am not sure how to use GuiCtrlRead to pick up the user input (for at least 1 variable) expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $add_GUI = 9999, $del_GUI = 9999 Global $add_add = 9999, $close_add = 9999 Global $del_del = 9999, $close_del = 9999 main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_bttn ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable button once pressed add_func () Case $del_bttn GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed del_func() EndSwitch Case $add_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_add GUIDelete($add_GUI) $add_add = 9999 $close_add = 9999 GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $add_add Local $number_add = "" MsgBox($MB_SYSTEMMODAL, "Adding", "Display Gui add input " & GUICtrlRead($number_add)) EndSwitch Case $del_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_del GUIDelete($del_GUI) $del_del = 9999 $close_del = 9999 GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $del_del Local $number_del = "" MsgBox($MB_SYSTEMMODAL, "Adding", "Display Gui delete input " & GUICtrlRead($number_del)) EndSwitch EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_GUI = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $add_add = GUICtrlCreateButton("Add action", 210, 225) $close_add = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Func del_func () ; GUI size for the window $del_GUI = GUICreate("Delete GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_del = GUICtrlCreateInput("", 130, 160, 90) $del_del = GUICtrlCreateButton("Delete action", 210, 225) $close_del = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Link to comment Share on other sites More sharing options...
zetaimmersion Posted March 18, 2017 Author Share Posted March 18, 2017 great success! - please close this before i get dumber! ... the final code to get user input looks like this. Hope it helps others. expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $add_GUI = 9999, $del_GUI = 9999 Global $add_add = 9999, $close_add = 9999 Global $del_del = 9999, $close_del = 9999 Global $number_add, $number_del main_window_selection () Func main_window_selection () $main_GUI = GUICreate("Main Gui", 300, 200) Local $add_bttn = GUICtrlCreateButton("Add", 20, 20, 85, 25) Local $del_bttn = GUICtrlCreateButton("Delete", 20, 70, 85, 25) Local $close_bttn = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUISetState() While 1 $get_gui_msg = GUIGetMsg(1) Switch $get_gui_msg[1] Case $main_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_bttn ExitLoop Case $add_bttn GUICtrlSetState($add_bttn, $GUI_DISABLE) ; disable button once pressed add_func () Case $del_bttn GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed del_func() EndSwitch Case $add_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_add GUIDelete($add_GUI) $add_add = 9999 $close_add = 9999 GUICtrlSetState($add_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $add_add ;Local $returned_user_add_input = 9999 MsgBox($MB_SYSTEMMODAL, "Adding", "Display Gui delete input " & GUICtrlRead($number_add)) EndSwitch Case $del_GUI Switch $get_gui_msg[0] Case $GUI_EVENT_CLOSE, $close_del GUIDelete($del_GUI) $del_del = 9999 $close_del = 9999 GUICtrlSetState($del_bttn, $GUI_ENABLE) ;re-enable buttons once gui2 closed Case $del_del MsgBox($MB_SYSTEMMODAL, "Adding", "Display Gui delete input " & GUICtrlRead($number_del)) EndSwitch EndSwitch WEnd EndFunc Func add_func () ; GUI size for the window $add_GUI = GUICreate("Add GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_add = GUICtrlCreateInput("", 130, 160, 90) $add_add = GUICtrlCreateButton("Add action", 210, 225) $close_add = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc Func del_func () ; GUI size for the window $del_GUI = GUICreate("Delete GUI", 350, 350) ;GUICtrlCreateLabel GUICtrlCreateLabel ("Input Field 1", 130,140) $number_del = GUICtrlCreateInput("", 130, 160, 90) $del_del = GUICtrlCreateButton("Delete action", 210, 225) $close_del = GUICtrlCreateButton("Close", 230, 320,50) GUISetState() EndFunc 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