Audrey Posted April 27, 2011 Share Posted April 27, 2011 Hi All, I'm Audrey (the female newbie) and super fresh on AutoIt. My first problem writing a script is perhaps a simple one for you out there! In the code below you have a mainpage and a button. Pressing the button will open the Msgbox. Now, I want to force the close the Msgbox first (by clicking the OK button) before he can continue with mainpage. This box would be a message or something, that has to be confirmed by the user, before he can do anything else. I tried the Disable/Enable and the lock/unlock function, but it was not working.. Can this be done? All the best, Audrey #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example1() ; example 1 Func Example1() Local $msg, $button GUICreate("Mainpage") $button = GUICtrlCreateButton("Button", 30, 30, 70) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $button Then MsgBox(0, "Help", "Please close me!") WEnd GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 27, 2011 Moderators Share Posted April 27, 2011 Audrey,Welcome to the AutoIt forum. Take a look at the Modal MsgBox Styles tutorial in the Wiki - it will explain how to set the style of your MsgBox to prevent the user from interacting with the main GUI until the MsgBox is cleared. Come back if you are still unclear. 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...
sahsanu Posted April 27, 2011 Share Posted April 27, 2011 (edited) I tried the Disable/Enable and the lock/unlock function, but it was not working.. Melba23 already pointed out how to solve your problem, anyway, I'm just curious why disable/enable is not working. I tried it and it worked fine changing this: If $msg = $button Then MsgBox(0, "Help", "Please close me!") to this: If $msg = $button Then GUISetState(@SW_DISABLE) MsgBox(0, "Help", "Please close me!") GUISetState(@SW_ENABLE) EndIf Edit: I mistyped Melba's nick Edited April 27, 2011 by sahsanu Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 27, 2011 Share Posted April 27, 2011 Or set the "parent" param of MsgBox .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
martin Posted April 27, 2011 Share Posted April 27, 2011 Or set the "parent" param of MsgBoxYes, I think that is the best way, everyone should do it! You don't have to remember so many funny numbers and the dialog flashes if you click on the parent. (And it should be in the Wiki). Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 27, 2011 Moderators Share Posted April 27, 2011 martin,it should be in the WikiIt is now! AdmiralAlkex,Thanks for the suggestion. 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...
sahsanu Posted April 27, 2011 Share Posted April 27, 2011 Yes, I think that is the best way, everyone should do it! I think so too. @Audrey, this is what Melba23 said: MsgBox(8192, "Help", "Please close me!") ;pay attention to 8192 and this is an example using parent as suggested by AdmiralAlkex and Martin . #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example1() ; example 1 Func Example1() Local $msg, $button, $mygui $mygui=GUICreate("Mainpage") $button = GUICtrlCreateButton("Button", 30, 30, 70) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $button Then MsgBox(0, "Help", "Please close me!","",$mygui) WEnd GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
Audrey Posted April 29, 2011 Author Share Posted April 29, 2011 Hi Guys (I assume) I did not know there were replies already, because my notification button was switched off. Thanks for all the solutions. This will help me a lot further! My new newbie questions will be posted soon. Greetings, Audrey 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