AnonymousX Posted March 25, 2017 Posted March 25, 2017 (edited) Hello, I'm trying to make it so that when a message box pops up that the GUI will be unresponsive until that message box has been closed. From reading through the help the closest thing I can find is the WinWaitClose function, however this doesn't work fully as desired. If user tries to click on GUI the actions are more just waiting for the message box to close, so that once it closes everything happens at once. I want it so that the GUI is completely unusable until message box is closed. Below is test code to demonstrate the problem and help explain what I want. Any advice on this? #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) local $but = GUICtrlCreateButton("Hello", 150,150,85,25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox( 262144,"Message","Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit case $but MsgBox(0,"","Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Edited March 27, 2017 by AnonymousX
232showtime Posted March 25, 2017 Posted March 25, 2017 (edited) #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Local $but = GUICtrlCreateButton("Hello", 150, 150, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_DISABLE, $hGUI) ;added MsgBox(262144, "Message", "Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") GUISetState(@SW_ENABLE, $hGUI);added ;~ WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit Case $but MsgBox(0, "", "Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example EDIT: check the help file for additional info Edited March 25, 2017 by 232showtime AnonymousX 1 ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
Moderators Melba23 Posted March 25, 2017 Moderators Posted March 25, 2017 AnonymousX, A better solution is to set the correct style for the MsgBox like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) local $but = GUICtrlCreateButton("Hello", 150,150,85,25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox($MB_TOPMOST + $MB_TASKMODAL,"Message","Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit case $but MsgBox(0,"","Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example All is explained in the Modal MsgBox Styles tutorial in the Wiki. M23 spudw2k, Colduction, AnonymousX and 1 other 3 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
Trong Posted March 26, 2017 Posted March 26, 2017 Normal way: #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Local $but = GUICtrlCreateButton("Hello", 150, 150, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(262144, "Message", "Try hitting the hello button several times,without closing this window. " & _ "Now close this window and see how script wasn't restricted it just was waiting and storing the instructions", 0, $hGUI) ;~ WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit Case $but MsgBox(0, "", "Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
AnonymousX Posted March 27, 2017 Author Posted March 27, 2017 (edited) Thanks everyone for the help! Special thanks to you Melba23, That is exactly how I thought it should be done, I just would have never known by the description in the message box help what " Task modal " meant, and never would have thought to test that. Thanks for helping! Edited March 27, 2017 by AnonymousX
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