xuzo Posted July 14, 2012 Share Posted July 14, 2012 Wondering why the task is not going to next step: MsgBox(64, "A", "B") here is the code:#include #include #include #include #include #region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 466, 202) Local $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) Local $BrowserType = GUICtrlCreateInput("Please Select Browser Type", 176, 120, 121, 21) Local $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) Exit EndSwitch WEnd MsgBox(64, "A", "B") Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 Because the only statement that whill ever leave the "While 1 / WEnd" loop exits the script and therefore never executes the MsgBox statement. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2012 Moderators Share Posted July 14, 2012 xuzo,Because you tell the script to "Exit" when the edit control is actioned - you need to use "ExitLoop" so that the script cntinues. 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...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 I sound sooooo stupid..but trying! Tried both ways, not working: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) Exit EndSwitch WEnd Exit MsgBox(64, "A", "B") And : While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) Exit EndSwitch WEnd ExitLoop MsgBox(64, "A", "B") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2012 Moderators Share Posted July 14, 2012 xuzo, #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 466, 202) $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) $BrowserType = GUICtrlCreateInput("Please Select Browser Type", 176, 120, 121, 21) $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd MsgBox(64, "A", "B") And anyway why are you not using a combo to get the selection? 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...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 Thanks, works now! I'm missing so many basics...like learning to be a carpenter, I can use a hammer but don't know what a nail is...! I have more stupid questions comming unfortunately... Cheers! Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 No problem, let them roll in. We'll try to answer any question as long as we can see some effort from your side. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 Great! Ok, here's one more! Is it better to open a new thread or keep going with the one started by the way? So now I want to wait until the GUI is gone before moving on. I've experimented with Sleep, and WinWait, WinWaitClose ect...but can't seem to get it right...here it is: #include #include #include #include #include $Form1 = GUICreate("Form1", 400, 400) $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) $BrowserType = GUICtrlCreateInput("Please Select Browser Type", 176, 120, 121, 21) $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType ;sgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd WinWaitClose("Form1") Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send(GUICtrlRead($BrowserType)) WinClose("Untitled - Notepad") Send("!n") Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 Use function GUIDelete if the GUI is no longer needed. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2012 Moderators Share Posted July 14, 2012 xuzo, Just amend the action to take when the GUI is closed: #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 400, 400) $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) $BrowserType = GUICtrlCreateInput("Please Select Browser Type", 176, 120, 121, 21) $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) EndSwitch WEnd MsgBox(0, "Hi", "GUI closed") Is it better to open a new thread or keep going with the one started by the way?If your new question is closely related to the thread then by all means keep going. But if you are going off on a tangent then please start a new one. Not that you need much encouragement to do so so far. 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...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 Thank GUIDelete() does work, but then I loose the value...it kills everything: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType ;sgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd GUIDelete() Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send(GUICtrlRead($BrowserType)) WinClose("Untitled - Notepad") Send("!n") Then I tried this but doesn't work: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType ;sgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd GUI_EVENT_CLOSE() Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send(GUICtrlRead($BrowserType)) WinClose("Untitled - Notepad") Send("!n") Not working: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType ;sgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd WinWaitClose("Form1") Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send(GUICtrlRead($BrowserType)) WinClose("Untitled - Notepad") Send("!n") Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 But if you want to remove the GUI from the screen before your script is closed you need to use GUIDelete. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 You have to store the selection in a variable because all GUI related functions return an error when called after GUIDelete. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType $sSelection = GUICtrlRead($BrowserType) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd GUI_EVENT_CLOSE() Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send($sSelection) WinClose("Untitled - Notepad") Send("!n") My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 Thanks Melba, I tried your script and works fine, but I want the GUI to close itself alone after clicking on submit without having to click on the Minimize X Trying this now: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType ;sgBox(64, "You selected:", GUICtrlRead($BrowserType)) ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WinClose("Form1") WEnd WinWaitClose("Form1") Run("notepad.exe") Sleep(1000) WinWait("Untitled - Notepad") Send(GUICtrlRead($BrowserType)) WinClose("Untitled - Notepad") Send("!n") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2012 Moderators Share Posted July 14, 2012 xuzo, You need to phrase your questions better - you asked how to wait until the GUI had closed, not how to close it! And water has already given you the answer: #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 400, 400) $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) $BrowserType = GUICtrlCreateInput("Please Select Browser Type", 176, 120, 121, 21) $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BrowserType MsgBox(64, "You selected:", GUICtrlRead($BrowserType)) GUIDelete($Form1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ExitLoop EndSwitch WEnd MsgBox(0, "Hi", "GUI closed") 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...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 (edited) Hi Water, Thank you, that's exactly what I wanted to do! Edited July 14, 2012 by xuzo Link to comment Share on other sites More sharing options...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 (edited) Hi Melba, yes, sorry, not always sure how to ask, might be better to go little steps by steps and thread by thread? One small question at a time is better I think? Indeed the code that water gave is 100% what I wanted to do. Thanks Edited July 14, 2012 by xuzo Link to comment Share on other sites More sharing options...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 [solved] Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 Using variables and creating simple GUIs are such basic tasks that I would recommend (before you do further coding) to have a look at the Wiki and check the tutorials. There you find good descriptions and examples how things work. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
xuzo Posted July 14, 2012 Author Share Posted July 14, 2012 Hi Water, Thanks for the link, I've been to that page and checked all the links;) I read everything....problem is I lack the basics, I mean all I know is like stuff from high school 25 years ago like: X=Y and Y=Z so X=Z ...that is basically the extend of my knowledge about that type of programming although I know HTML and CSS...! Cheers! 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