SoFunction
Updated on 2025-04-12

autoit InputBox function

Function descriptionInputBox

Displays as an input box for the user to enter data. InputBox ("Title", "Tip" [, "Default Data" [, "Password Character" [, Width, Height [, Left, Top [, Timeout]]]]]] )

 

parameter

title Enter the title text of the box.
Prompt information Prompt the user with the data that the program needs to obtain.
Default data The default text displayed in the input text box.
Password characters [Optional Parameters] Displays characters used in the input text box to replace the user's input characters. If you want to display characters normally, just define this parameter as an empty string "" (default) or a space character. If this parameter is set to a multi-character string, only the first character is valid. The second character and other characters after it have other special purposes. Please check the note section below.
width [Optional Parameters] Window width. If this parameter is specified, the height parameter must also be specified. Specifying -1 means using the default width.
high [Optional Parameters] Window height. If this parameter is specified, the width parameter must also be specified. Specifying -1 means using the default height.
left [Optional Parameters] The distance (pixel) to the left of the input box from the left of the screen. By default, the input box is displayed in the center. If this parameter is specified, the above parameter must also be specified.
Above [Optional Parameters] The distance (pixel) from the top of the input box to the left of the screen. By default, the input box is displayed in the center, and if this parameter is specified, the left parameter must also be specified.
Timeout [Optional Parameters] In seconds. The input box will automatically close after the specified time.

 

Return value

success: Returns the string entered by the user.
fail: Return an empty string and set @error to one of the following values:
@Error 0 = The returned string is valid.
1 = The user pressed the Cancel button.
2 = Timeout.
3 = The input box fails to display, which is usually caused by invalid parameters.

 

Notice

Use BlockInput(1) to block the user from entering data (Windows 98/Me).

The user can adjust the window size of the input box, but has a minimum size limit: approximately 190 x 115 (pixels). The default size is approximately 250 x 190 (pixels).

The returned string will not exceed 254 characters. If the input contains carriage return or newline characters, the returned string will be disconnected by the first of these characters.

Password Character The second and subsequent other characters of the parameter can be used to restrict user input. If the first character is a space, the input character will be visible, if the second character isMThat means the input will be mandatory (Mandatory), that is, the user must enter at least one character, if pressed without entering anythingOkThe script will not react in any way, and the input box will neither disappear nor return the string.

You can also add a number after the Password Character parameter to specify the maximum length of the input string (see the example below).

 

Related

MsgBox

 

Example


;The following input box will be displayed in the upper left corner of the screen and the corresponding prompt text will be displayed.
$answer = InputBox("question", "Where is your birthplace?", "Earth", "", _
    -1, -1, 0, 0)

;Require the user to enter a password. Don’t forget to provide another confirmation password in the actual program code!
$passwd = InputBox("Permission Verification", "Please enter your password:", "", "*")

;Requires the user to enter characters 1 or 2. M in the password character parameter means that the empty string is not accepted.
;The number 2 means that at most two characters can be entered.
$value = InputBox("test", "Please enter character 1 or 2:", "", " M2")