Hide Comments
Purpose:Display a Windows message box

 

Format:MSGBOX [/1["text"] /2["text"] /3["text"] /4["text"] /5["text"] /6["text"] /Brgb /Dn /H /I /L /M /N /O /Px,y /Q /R /S /Tn /V /W] buttontype ["title"] prompt

 

buttontypeOne of OK, OKCANCEL, YESNO, YESNOCANCEL, RETRYCANCEL, ABORTRETRYIGNORE, CANCELTRYCONTINUE, CONTINUEABORT, SKIPSKIPALLCANCEL, or IGNOREIGNOREALLCANCEL
titleText for the title bar of the message box.
promptText that will appear inside the message box.

 

/1 (st button)/L(imit width)
/2 (nd button)/M (system modal)        
/3 (rd button) /N (no sound)        
/4 (th button)/O (topmost window)        
/5 (th button)/P (screen coordinates)
/6 (th button)/Q(uestion icon)
/B (background color)/R(ight justify buttons)        
/F (foreground color)/S(top icon)
/D(isable temporarily)/T(imeout)        
/H(elp button)/V(ista style)        
/I(nformation icon)/W(arning icon)        

 

See also: INKEY, INPUT, QUERYBOX, and TASKDIALOG.

 

Usage:

 

MSGBOX can display one of eight kinds of message boxes and wait for the user's response. You can use title and prompt to display any text you wish. TCC will automatically size and center the message box on the screen. The message box has up to three response buttons (plus an optional Help button), depending on its type, as shown below.

 

buttontype

button 1

button 2

button 3

OK

OK



OKCANCEL

OK

Cancel


YESNO

Yes

No


YESNOCANCEL

Yes

No

Cancel

RETRYCANCEL

Retry

Cancel


ABORTRETRYIGNORE

Abort

Retry

Ignore

CANCELTRYCONTINUE

Cancel

Try Again

Continue

CONTINUEABORT

Continue

Abort


SKIPSKIPALLCANCEL

Skip

Skip All

Cancel

IGNOREIGNOREALLCANCEL

Ignore

Ignore All

Cancel

 

There are two button type modifiers (only valid when used immediately following a YESNO or YESNOCANCEL):

 

YESTOALL - adds a "Yes to All" button (returns 30)

NOTOALL - adds a "No to All" button (returns 31)

 

If the standard message box types don't meet your needs, you can create a custom message box with up to four buttons (plus an optional Help button), specifying the text that appears on each button.

 

The button the user chooses is indicated using the internal variable %_?. Be sure to save the return value in another variable or test it immediately; because the value of %_? changes with every internal command. The following list shows the value returned for each selection:

 

response

%_?

Yes or OK

10

No

11

Cancel

12

Retry

13

Try Again

14

Continue

15

Ignore

16

Abort

17

Help

18

timeout

20

custom button 1

21

custom button 2

22

custom button 3

23

custom button 4

24

custom button 5

25

custom button 6

26

 

If you define custom buttons, the button type argument will be ignored.

 

 

There are three optional Checkbox types. (You can only choose one at a time.)

 

DONOTASKAGAIN - add checkbox "Do not ask me again".

DONOTTELLAGAIN - add checkbox "Do not tell me again"

DONOTSHOWAGAIN - add checkbox "Do not show again"

 

If the checkbox is selected, MSGBOX will set the internal variable %_msgbox_checkbox to 1.

 

If there is an error in the MSGBOX command itself, %_? will be set as described in its documentation (see _?).

 

For example, to display a Yes or No message box and take action depending on the result, you could use commands like this:

 

msgbox yesno "Copy" Copy all files to A:?

if %_? == 10 copy * a:

 

Since MSGBOX doesn't write to standard output, it disables redirection and piping to allow you to enter the redirection characters (<, >, and |) in your prompt text.

 

MSGBOX creates a popup dialog box. If you prefer to retrieve input from the command line, see the INKEY and INPUT commands.

 

Options:

 

/1If there is a text string following the option, set the custom text for the first button. Otherwise, set the first button as the default.

 

/2 If there is a text string following the option, set the custom text for the second button. Otherwise, set the second button as the default.

 

/3If there is a text string following the option, set the custom text for the third button. Otherwise, set the third button as the default.

 

/4If there is a text string following the option, set the custom text for the fourth button. Otherwise, set the fourth button as the default.

 

/5If there is a text string following the option, set the custom text for the fifth button. Otherwise, set the fifth button as the default.

 

/6If there is a text string following the option, set the custom text for the sixth button. Otherwise, set the sixth button as the default.

 

/BrgbBackground color (in RGB hex format).

 

/DnDisable the message box buttons for n seconds at startup.

 

/FrgbText color (in RGB hex format).

 

/HDisplay a help button.

 

/IDisplay an icon consisting of a lower case "i" in a circle in the message box.

 

/LLimit the maximum message box width to no more than 1/3 the screen width (unless the button text requires more).

 

/MThe message box window will be displayed on top of all other windows.

 

/NDon't play the default sound.

 

/O The message box is created as a topmost window.

 

/Px,yThe initial x,y screen coordinates. If you don't use this option, MSGBOX will center its window in the TCC tab window.

 

/QDisplay a question mark icon in the message box.

 

/RThe buttons will be right-justified.

 

/SDisplay a stop sign icon in the message box.

 

/TnMSGBOX will wait a maximum of n seconds for a response (and then close). If the time limit expires, %_? will be set to 20. The time remaining before the window closes will be displayed in the default button.

 

/VDisplay the message box in the Windows 7 / 8 / 10 style (the message background will be the current window color, the buttons will be right-justified and slightly bigger, and the position of icon and message will be adjusted.) This is the default in Windows 7 and later.

 

/WDisplay an exclamation point icon in the message box.