ChrisL Posted June 11, 2006 Share Posted June 11, 2006 (edited) This is a merge of 2 UDF's to chang the text on msgbox buttons and also to move the message box to a location on the screenexpandcollapse popup;=============================================================================== ; ;~ Function: _MsgBoxChangeButtons() ;~ Desctiption Changes the position of and button text of a MsgBox() ;~ Version: N/A ;~ Original UDF's HerewasPlato and Smoke_N ;~ Author: ChrisL ;~ Parameter(s): ;~ $iMBFlag = Icon and or Flags (Type of buttons) ;~ $MBTitle = Title of MsgBox() ;~ $MBText = Text for the Body of the MsgBox() ;~ $MBButton1 = Text to change the first button ;~ $MBButton2 = Optional Param: Text to change the second Button if applicable ;~ $MBButton3 = Optional Param: Text to change the third Button if applicable ;~ $iMBTimeOut = Optional Param: MsgBox() Time out ;~ $xMBpos = Optional Param: X coordinate to move to. Default no move is "" ;~ $yMBpos = Optional Param: y coordinate to move to. Default no move is "" ;~ Requirement(s): AutoIt Beta 3.1xx ;~ Example: ;~ _MsgBoxChangeButtons(36, 'My Title', 'My Text', 'Button 1', 'Button 2', '', 3,100,20) ;~ Example Result: Will turn out a MsgBox() instead of Yes and No button will be Button 1 and Button 2 with a time out of 3 seconds at x 100 and y 20 ;~ Return Value(s): Will return the value that was clicked in the MsgBox() ;~ Return Value -1 incorrect parameter see @error for details ;~ @error 1 $iFlag is not numerical ;~ @error 2 $iMBTimeOut is not numerical ;~ @error 3 $xMBpos is not numerical ;~ @error 4 $yMBpos is not numerical ; ;=============================================================================== Func _MsgBoxChangeButtons($iFlag, $sTitle, $sText, $sButton1, $sButton2 = '', $sButton3 = '', $iMBTimeOut = 0, $xMBpos = "", $yMBpos = "") If Not IsNumber ($iFlag) then Seterror (1 ) Return -1 ElseIf Not IsNumber ($iMBTimeOut) then Seterror (2 ) Return -1 ElseIf $xMBpos <> "" and IsNumber ($xMBpos) = 0 then Seterror (3 ) Return -1 ElseIf $yMBpos <> "" and IsNumber ($yMBpos) = 0 then Seterror (4 ) Return -1 Endif Local $MBFile = FileOpen(@TempDir & '\MiscMMB.txt', 2) Local $MBLine0 = '' Local $MBLine1 = '#NoTrayIcon' Local $MBLine2 = 'Opt("WinWaitDelay", 0)' Local $MBLine3 = 'WinWait("' & $sTitle & '")' Local $MBLine4 = 'ControlSetText("' & $sTitle & '", "", "Button1", "' & $sButton1 & '")' Local $MBLine5 = 'ControlSetText("' & $sTitle & '", "", "Button2", "' & $sButton2 & '")' Local $MBLine6 = 'ControlSetText("' & $sTitle & '", "", "Button3", "' & $sButton3 & '")' Local $MBline7 = 'WinMove("' & $sTitle & '", ""' & ', ' & $xMBpos & ', ' & $yMBpos & ')' Local $MBline8 = '$pos = WingetPos("' & $sTitle & '", "")' Local $MBline9 = 'WinMove("' & $sTitle & '", ""' & ', ' & $xMBpos & ',$pos[1])' Local $MBline10 = 'WinMove("' & $sTitle & '", ""' & ', $pos[0], ' & $yMBpos & ')' If $sButton2 = '' Then FileWrite(@TempDir & '\MiscMMB.txt',$MBLine0 & @crlf & $MBLine1 & @CRLF & $MBLine2 & @CRLF & $MBLine3 & @CRLF & $MBLine4) ElseIf $sButton2 <> '' And $sButton3 = '' Then FileWrite(@TempDir & '\MiscMMB.txt',$MBLine0 & @crlf & $MBLine1 & @CRLF & $MBLine2 & _ @CRLF & $MBLine3 & @CRLF & $MBLine4 & @CRLF & $MBLine5) ElseIf $sButton2 <> '' And $sButton3 <> '' Then FileWrite(@TempDir & '\MiscMMB.txt',$MBLine0 & @crlf & $MBLine1 & @CRLF & $MBLine2 & @CRLF & _ $MBLine3 & @CRLF & $MBLine4 & @CRLF & $MBLine5 & @CRLF & $MBLine6) EndIf If $xMBpos <> "" and $yMBpos <> "" then FileWriteLine(@TempDir & '\MiscMMB.txt', @crlf & $MBLine7) ElseIf $xMBpos <> "" and $yMBpos = "" then FileWriteLine (@TempDir & '\MiscMMB.txt', @crlf & $MBLine8) FileWriteLine (@TempDir & '\MiscMMB.txt', @crlf & $MBLine9) Elseif $xMBpos = "" and $yMBpos <> "" then FileWriteLine (@TempDir & '\MiscMMB.txt', @crlf & $MBLine8) FileWriteLine (@TempDir & '\MiscMMB.txt', @crlf & $MBLine10) Endif $MBPID1 = Run(@AutoItExe & ' /AutoIt3ExecuteScript ' & EnvGet('TEMP') & '\MiscMMB.txt') $MBBox = MsgBox($iFlag, $sTitle, $sText, $iMBTimeOut) FileClose($MBFile) Do FileDelete(@TempDir & '\MiscMMB.txt') Until Not FileExists(@TempDir & '\MiscMMB.txt') Return $MBBox EndFuncHerewasplato's UDF http://www.autoitscript.com/forum/index.php?showtopic=22531Smoke_N's UDF http://www.autoitscript.com/forum/index.php?showtopic=27491EditChanged the -1 param to "" and added some @errors if Letters are used instead of numbers in the numerical parameters Edited June 7, 2008 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
herewasplato Posted June 11, 2006 Share Posted June 11, 2006 Wish I had thought of that - great UDF...You might consider this small change mentioned here:http://www.autoitscript.com/forum/index.ph...ndpost&p=195036 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ChrisL Posted June 11, 2006 Author Share Posted June 11, 2006 Wish I had thought of that - great UDF...You might consider this small change mentioned here:http://www.autoitscript.com/forum/index.ph...ndpost&p=195036Cheers I only modified yours and Smokes put your new suggestion in and added some @errors [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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