CyberSlug Posted January 5, 2005 Share Posted January 5, 2005 I thought I would attempt to provide an easy way to change the button text of MsgBox with the following constraints:- does not use GUI functions- does not rely on a second script (neither an entirely separate script, nor FileWriteLine'd script, nor FileInstall'd script).Requires latest AutoIt beta; should work on uncompiled and compiled scripts.The following is designed to be Include'd (or inserted directly) at the very beginning of your program.expandcollapse popup#include-once #NoTrayIcon __Do_Main() ;Expects 2 to 5 command-line parameters: ; Title of MsgBox to watch for ; Text of MsgBox to watch for ; Text to show for first button ; Text to show for second button ; Text to show for third button (if applicable) ; Wrap the body of the script in a function so as not to pollute global variable space... ; I also chose a function name that should not conflict with Func __Do_Main() Local $numArgs = $CmdLine[0] If $numArgs < 2 Then Return Local $title = $CmdLine[1], $text = $CmdLine[2] Local $winWaitDelay = Opt("WinWaitDelay", 5) If $text = "" Then WinWait($title) Else WinWait($title, $text) EndIf Opt("WinWaitDelay", $winWaitDelay) ;I wonder if the If statements or For-loop is more efficient ;;If $numArgs > 2 Then ControlSetText($title, $text, "Button1", $CmdLine[3]) ;;If $numArgs > 3 Then ControlSetText($title, $text, "Button2", $CmdLine[4]) ;;If $numArgs > 4 Then ControlSetText($title, $text, "Button3", $CmdLine[5]) For $i = 3 to $numArgs ControlSetText($title, $text, "Button" & ($i-2), $CmdLine[$i]) Next Exit EndFunc ; The command you use to create custom MsgBox buttons Func SetMsgBoxButtons($title, $text, $first = "", $second = "", $third = "") Local $cmd = '"' & @ScriptFullPath & '" "' & $title & '" "' & $text & '"' If @NumParams > 2 Then $cmd = $cmd & ' "' & $first & '"' If @NumParams > 3 Then $cmd = $cmd & ' "' & $second & '"' If @NumParams > 4 Then $cmd = $cmd & ' "' & $third & '"' If @Compiled Then Return Run($cmd, "", @SW_HIDE) Else Local $AutoIt = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\AutoIt3.exe" If FileExists($AutoIt) Then Return Run('"' & $AutoIt & '" ' & $cmd, "", @SW_HIDE) EndIf EndFuncExample usage. Notice that you call SetMsgBoxButtons before the MsgBox. That's all folks! #include "MsgBoxInc.au3" Opt("TrayIconHide", 0);show tray icon $title = "Example" $text = "What do you think?" SetMsgBoxButtons($title, $text, "Good", "Fair", "Poor") MsgBox(4099, $title, $text) SetMsgBoxButtons($title, "Second Example", "Okay!") MsgBox(4096, $title, "Second Example")Limitations:Scripts that rely on command-line paramters would need to be modified...SetMsgBoxButtons does not like an empty text paramterThere is a slight delay before the button text is updated, so the old text can be seen for a split second Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
sykes Posted January 5, 2005 Share Posted January 5, 2005 (edited) U Da Man CS! Edited January 5, 2005 by sykes We have enough youth. How about a fountain of SMART? 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