Alert (message1, message2, ok, cancel, other, timeoutsecs)

Result type:  number

Definition:  The Alert function displays an alert window with up to 3 buttons.

Both message strings will be included in the alert box (on Mac, the first message is larger and bolder).

ok, cancel, and other are optional button names. If supplied, buttons with those names will be included. If those parameters are omitted, the default alert has two buttons ("OK", and "Cancel"). To get just one button, pass "" for the Cancel button name. To get 3 buttons, provide names for all three.

If timeoutsecs is provided, the alert will auto-dismiss after that many seconds, as if the Cancel button was pressed.

The return value is a button number. 1 is OK, 2 is cancel, 3 is other. If the alert timed out, the result is 2.


let r = Alert("Approve transaction?", "You have the power", "Approve", "Don't Approve")

Help button: Alerts posted by this function in a script will include a help button. Clicking that help button will display another alert that identifies the script name and its meta string. Clicking the help button in that alert will bring you to this manual page via the manual search function. Clicking the help button in an alert posted from a non-script expression will go directly to the manual search.

Getting out of an endless alert loop: If you have written a script that is continuously posting alerts in a loop, you can force the script to stop by holding down the Control key when you click one of the alert's (non-help) buttons (provided that you have the Scripting privilege).

Availability:  available anywhere, but should usually only be used from MWScript handlers.

See Also:

Ask: Very simple dialog box with controls

ChooseFromList: Very simple list dialog box

Say: Speak some text