Moderators SmOke_N Posted July 19, 2010 Moderators Share Posted July 19, 2010 (edited) A while back, a few of us came up with a method to move the MsgBox window and to change button text. It was rather clumsy. I wrote a dll solution for moving the MsgBox to the center of the parent GUI window that owned it for most of my personal work. I decided to port it over to AutoIt rather continue to port the dll with all my AutoIt work, in addition I added the button text changing to the solution as well. The examples should be self explanatory on how to use the functions provided. * Note - I did not take the time to a $MB_OK type of Constant variable, they are there ( eg. $__iMsgBox_IDOK ), but they are designed for internal use only.Example: #include <MsgBoxUDF.au3> #region 3 piece function call ; Regardless of Coords, if a handle is passed, it will center messagebox to window of handle _MsgBox_SetWindowPos(200, 100) ; The same flag passed for buttons 0-6 should be set for both messagebox and setbuttontext _MsgBox_SetButtonText(4, "Button1", "Button2") _MsgBox(4 + 262144, "Title", "Hello World One") Sleep(250) ; See now that it reset back to default _MsgBox(4 + 262144, "Title", "Hello World Two") #endregion 3 piece function call #region stand alone all in one call Sleep(250) ; Change buton 1 to Button1; Move to top left corner of desktop _MsgBoxEx(4 + 262144, "Title", "Hello World Three", -1, -1, "Button1", -1, -1, 0, 0) Sleep(250) ; Center to active window _MsgBoxEx(4 + 262144, "Title", "Hello World Four", -1, WinGetHandle(""), -1, "Button2", -1, 0, 0) #endregion stand alone all in one call MsgBoxUDF.au3 Edited July 23, 2012 by SmOke_N simplercoder000, mLipok and argumentum 3 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2010 Share Posted July 20, 2010 This is quite handy. Thanks for sharing. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 22, 2010 Author Moderators Share Posted July 22, 2010 I use the method often. Especially for centering to parent GUI. Always drove me crazy to have my message box outside my GUI if I put it somewhere other than it's default location. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted July 20, 2012 Share Posted July 20, 2012 (edited) hey smoke, thanks for the UDF =) i have success renaming 2 buttons but not with 3. any ideas? _MsgBox_SetButtonText(6, "text1", "text2", "text3") $prompt = _MsgBox(6, "Title", "test?") thanks again for sharing Edited July 20, 2012 by gcue Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 21, 2012 Author Moderators Share Posted July 21, 2012 I revised the function, try the new udf download. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted July 23, 2012 Share Posted July 23, 2012 (edited) using this #include <msgboxudf.au3> _MsgBox_SetButtonText(6, "text1", "text2", "text3") _MsgBox(6, "Title", "test?") ;WORKS _MsgBox(6+262144, "Title", "test?") ;DOES NOT WORK thanks again for your help and the awesome UDF Edited July 23, 2012 by gcue Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 23, 2012 Author Moderators Share Posted July 23, 2012 I'm pretty sure I know where the issue is. I did one of those... just fix this fast and don't debug things. In order to fix the above, I'll have to look more which means I won't have time for a while, maybe the weekend or if I run into it too before then. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted July 23, 2012 Share Posted July 23, 2012 ok - thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 23, 2012 Author Moderators Share Posted July 23, 2012 (edited) Try it now Edit: FYI: The setbuttontext option clears once the _MsgBox() has been called and is reset to default. So, you'd have to do this each time: #include <msgboxudf.au3> _MsgBox_SetButtonText(6, "text1", "text2", "text3") _MsgBox(6, "Title", "test?") ;WORKS ; SetButtonText is reset after last _MsgBox(), so set text again _MsgBox_SetButtonText(6, "text4", "text5", "text6") _MsgBox(6+262144, "Title", "test?") Edited July 23, 2012 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted July 23, 2012 Share Posted July 23, 2012 works like a charm - thanks again smoke! Link to comment Share on other sites More sharing options...
horstj Posted January 29, 2013 Share Posted January 29, 2013 This UDF is great, but is there any way to create a msgbox centered to parent where the msgbox itself doesn't have to always be active? If I use the regular MsgBox() function I can leave the msgbox open while I continue doing other things manually in the background. However, if I use _MsgBoxEx() to center the msgbox, I cannot do anything until the msgbox goes away. I would really like to have both of these functionalities from one function! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2013 Moderators Share Posted January 29, 2013 (edited) horstj,MsgBox is a blocking function, so it is hardly surprising that you find your script blocked until you acknowledge it. Could I suggest either Yashied's NotifyBox or my Notify UDF (look in my sig for the link). You will probably have to rewrite SmOke_N's MsgBox-based UDF to get the NotifyBox to centre on your GUI (although I have not checked) - and my UDF slides in the notifications from the side of the screen. But if you want to keep the main GUI active you are a bit limited in your options. M23 Edited January 29, 2013 by Melba23 Fixed formatting - I hate this editor! 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...
JohnOne Posted January 29, 2013 Share Posted January 29, 2013 (edited) This UDF is great, but is there any way to create a msgbox centered to parent where the msgbox itself doesn't have to always be active? If I use the regular MsgBox() function I can leave the msgbox open while I continue doing other things manually in the background. However, if I use _MsgBoxEx() to center the msgbox, I cannot do anything until the msgbox goes away. I would really like to have both of these functionalities from one function!There are MessageBox flags which make it so the user must respond before you can manually do anything in any application.Perhaps this is one of those, I cannot remember, but be sure to provide the _MgsBoxEx() function with a hWnd parameter which might solve your problem. Edited January 29, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
horstj Posted January 30, 2013 Share Posted January 30, 2013 MsgBox is a blocking function, so it is hardly surprising that you find your script blocked until you acknowledge it. This may be so with _MsgBox() from this UDF, but the stock MsgBox() is not blocking. If you use the standard msgbox you can still do anything else while leaving the box open. I didn't look too long, but it seems that this UDF is more or less just modifying a basic msgbox. This leads me to believe that something in Sm0ke_N's code is altering the msgbox to make it a blocking function. Am I completely off base here? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 30, 2013 Moderators Share Posted January 30, 2013 horstj, but the stock MsgBox() is not blockingOh no? Run this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUISetState() MsgBox(0, "Hi", "Try and close the GUI before you close me!") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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...
JohnOne Posted January 30, 2013 Share Posted January 30, 2013 I think the guy means it blocks the ability to work on other applications. If smokes code calls MessageBox API and a certain flag is used without passing a handle to it (NULL) it blocks everything until it is addressed. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 30, 2013 Moderators Share Posted January 30, 2013 horstj, JohnOne, I know nothing about this UDF, nor the flags needed by the API. So I am out of here. 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...
horstj Posted January 30, 2013 Share Posted January 30, 2013 (edited) I think the guy means it blocks the ability to work on other applications. Right, sorry for the confusion there. I wasn't talking about being able to use the GUI that created the msgbox. Here is an exact example of what I am seeing: #include <GUIConstantsEx.au3> #include <MsgBoxUDF.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 190, 90) GUISetState() Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe -new https://www.google.com","") $WinHwnd = WinWaitActive("[CLASS:IEFrame]") GUICtrlCreateLabel("Click _MsgBoxEx first.", 40, 10) $_MsgBoxExButton = GUICtrlCreateButton("_MsgBoxEx",20,40,70,30,$BS_DEFPUSHBUTTON) $MsgBoxButton = GUICtrlCreateButton("MsgBox",100,40,70,30,$BS_DEFPUSHBUTTON) While 1 ; $msg = GUIGetMsg(1) Select Case $msg[0] = $_MsgBoxExButton _MsgBoxEx(0,"Hi", "Try to do anything in IE",-1,$WinHwnd) Case $msg[0] = $MsgBoxButton MsgBox(0,"Hi", "Now try to do anything in IE") Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $hGUI ExitLoop EndSelect WEnd The problem is that I cannot use IE when the _MsgBoxEx() function was used, but I would like the msgbox to be centered on the IE window. Edited January 30, 2013 by horstj Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 11, 2014 Author Moderators Share Posted February 11, 2014 Sorry to have taken so long to respond. I'm not on as much as I'd like to be. Having said that, it's been a long while since I've looked at this code. If I had to take a "stab" in the dark on why you're experienceing this behavior, the first thing I'd reserarch is the windows api SetWindowsHookEx. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
TheDcoder Posted March 19, 2015 Share Posted March 19, 2015 Excuse me, but can I know why is the below code not working? _MsgBoxEx(48, "Test", "Taste", -1, -1, "Pest", "Paste") EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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