Jump to content



Photo

Move msgbox and change the buttons


  • Please log in to reply
2 replies to this topic

#1 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 11 June 2006 - 12:39 PM

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 screen

Plain Text         
;=============================================================================== ; ;~ 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 EndFunc



Herewasplato's UDF http://www.autoitscript.com/forum/index.php?showtopic=22531

Smoke_N's UDF http://www.autoitscript.com/forum/index.php?showtopic=27491

Edit
Changed the -1 param to "" and added some @errors if Letters are used instead of numbers in the numerical parameters

Edited by ChrisL, 07 June 2008 - 01:06 PM.






#2 herewasplato

herewasplato

    Most Senile Poster

  • Active Members
  • PipPipPipPipPipPip
  • 4,426 posts

Posted 11 June 2006 - 04:08 PM

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
..

#3 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 11 June 2006 - 09:26 PM

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


Cheers I only modified yours and Smokes put your new suggestion in and added some @errors




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users