</head> <body> <h1>InputBox</h1> <p>Displays an input box to ask the user to enter a string.</p> <pre class="Syntax"><span class="func">InputBox</span>, OutputVar <span class="optional">, Title, Prompt, HIDE, Width, Height, X, Y, Locale, Timeout, Default</span></pre> <h2 id="Parameters">Parameters</h2> <dl> <dt>OutputVar</dt> <dd><p>The name of the variable in which to store the text entered by the user.</p></dd> <dt>Title</dt> <dd><p>The title of the input box. If blank or omitted, it defaults to the name of the script.</p></dd> <dt>Prompt</dt> <dd><p>The text of the input box, which is usually a message to the user indicating what kind of input is expected. If <em>Prompt</em> is long, it can be broken up into several shorter lines by means of a <a href="../Scripts.htm#continuation">continuation section</a>, which might improve readability and maintainability.</p></dd> <dt>HIDE</dt> <dd><p>If this parameter is the word HIDE, the user's input will be masked, which is useful for passwords.</p></dd> <dt>Width</dt> <dd><p>If this parameter is blank or omitted, the starting width of the window will be 375. This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd> <dt>Height</dt> <dd><p>If this parameter is blank or omitted, the starting height of the window will be 189. This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd> <dt>X, Y</dt> <dd><p>The X and Y coordinates of the window (use 0,0 to move it to the upper left corner of the desktop), which can be <a href="../Variables.htm#Expressions">expressions</a>. If either coordinate is blank or omitted, the dialog will be centered in that dimension. Either coordinate can be negative to position the window partially or entirely off the desktop.</p></dd> <dt>Locale <span class="ver">[v1.1.31+]</span></dt> <dd><p>If this parameter is the word Locale, the OK and Cancel buttons are named according to the current user's locale (for example, Abbrechen instead of Cancel on a German OS). In addition, to display these names correctly, the buttons are made wider and the minimum width of the input box is increased. This becomes the default behavior in <a href="https://www.autohotkey.com/v2/">AutoHotkey v2</a>.</p></dd> <dt>Timeout</dt> <dd><p>Timeout in seconds (can contain a decimal point or be an <a href="../Variables.htm#Expressions">expression</a>). If this value exceeds 2147483 (24.8 days), it will be set to 2147483. After the timeout has elapsed, the input box will be automatically closed and <a href="../misc/ErrorLevel.htm">ErrorLevel</a> will be set to 2. <em>OutputVar</em> will still be set to what the user entered.</p></dd> <dt>Default</dt> <dd><p>A string that will appear in the input box's edit field when the dialog first appears. The user can change it by backspacing or other means.</p></dd> </dl> <h2 id="Error_Handling">Error Handling</h2> <p><span class="ver">[v1.1.04+]</span>: This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p> <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> 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, <em>OutputVar</em> is set to the value entered. This allows the CANCEL button to perform a function other than CANCEL should the script designer wish it.</p> <h2 id="Remarks">Remarks</h2> <p>An input box usually looks like this:</p> <img src="../static/dlg_input.png" alt="InputBox" /> <p>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.</p> <p>A GUI window may display a modal input box by means of <a href="Gui.htm#OwnDialogs">Gui +OwnDialogs</a>. A modal input box prevents the user from interacting with the GUI window until the input box is dismissed.</p> <h2 id="Related">Related</h2> <p><a href="Gui.htm">GUI</a>, <a href="Input.htm">Input</a>, <a href="MsgBox.htm">MsgBox</a>, <a href="FileSelectFile.htm">FileSelectFile</a>, <a href="FileSelectFolder.htm">FileSelectFolder</a>, <a href="SplashTextOn.htm">SplashTextOn</a>, <a href="ToolTip.htm">ToolTip</a></p> <h2 id="Examples">Examples</h2> <div class="ex" id="ExPassword"> <p><a class="ex_number" href="#ExPassword"></a> Allows the user to enter a hidden password.</p> <pre>InputBox, password, Enter Password, (your input will be hidden), hide</pre> </div> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Allows the user to enter a phone number.</p> <pre>InputBox, UserInput, Phone Number, Please enter a phone number., , 640, 480 if ErrorLevel MsgBox, CANCEL was pressed. else MsgBox, You entered "%UserInput%"</pre> </div> </body> </html>