InputBox

Displays an input box to ask the user to enter a string.

OutputVar := InputBox(Text, Title, Options, Default)

Parameters

OutputVar

The name of the variable in which to store the text entered by the user.

Text

The text of the input box, which is usually a message to the user indicating what kind of input is expected. If Text is long, it can be broken up into several shorter lines by means of a continuation section, which might improve readability and maintainability.

Title

The title of the input box. If omitted, it defaults to the current value of A_ScriptName.

Options

A string of case-insensitive options, with each separated from the last by a space or tab.

Xn Yn: The X and Y coordinates of the dialog. For example, X0 Y0 puts the window at the upper left corner of the desktop. If either coordinate is omitted, the dialog will be centered in that dimension. Either coordinate can be negative to position the dialog partially or entirely off the desktop (or on a secondary monitor in a multi-monitor setup).

Wn Hn: The width and height of the dialog. For example, W375 H189 is the default size.

T: Specifies the timeout in seconds. For example, T10.0 is ten seconds. If this value exceeds 2147483 (24.8 days), it will be set to 2147483. After the timeout has elapsed, the InputBox window will be automatically closed and ErrorLevel will be set to 2. OutputVar will still be set to what the user entered.

Password: Mask the user's input. To specify which character is used, follow this example: Password*

Default

A string that will appear in the InputBox's edit field when the dialog first appears. The user can change it by backspacing or other means.

ErrorLevel

See below.

Remarks

The dialog allows the user to enter text and then press OK or CANCEL. The user can resize the dialog window by dragging its borders.

ErrorLevel is set to 1 if the user presses the CANCEL button, 0 if the user presses OK, or 2 if the dialog times out. In all three cases, OutputVar is set to the value entered. This allows the CANCEL button to perform a function other than CANCEL should the script designer wish it.

A GUI window may display a modal InputBox by means of OwnDialogs option. A modal InputBox prevents the user from interacting with the GUI window until the InputBox is dismissed.

Related

Gui object, Input, MsgBox, FileSelect, DirSelect, ToolTip

Example

password := InputBox("(your input will be hidden)", "Enter Password", "password") 
UserInput := InputBox("Please enter a phone number.", "Phone Number", "w640 h480")
if ErrorLevel
    MsgBox "CANCEL was pressed."
else
    MsgBox "You entered '" UserInput "'"