InputBox displays a popup box prompting the user to enter a string. Adapted from AutoIt doc.
$str = InputBox("title","prompt"[,"default"[,"password char[Option]"[,width[,height[,left,top[,timeout[,hwnd]]]]]])
|title||Sets the title of the input box|
|prompt||Sets the prompt to the user|
|default||Sets user input field to default text|
|password char||Set the character value to replace input.(Optional)|
|width||Set the width of the window in pixels. Height must also be set. Default value -1 or "Default".(Optional)|
|height||Set the height of the window in pixels. Width must also be set. Default value -1 or "Default".(Optional)|
|left||Set the distance of the window from the left side of the screen in pixels. Top must also be set. Default value -1 or "Default".(Optional)|
|top||Set the distance of the window from the top of the screen in pixels. Left must also be set. Default value -1 or "Default".(Optional)|
|timeout||Set the number of seconds till close.(Optional)|
|hwnd||Set the window handle as the parent.(Optional)|
Title, Prompt, & Default
The title, prompt, and default fields set the title of the box, the user prompt, and the initial value of the user input field respectively.
$str = InputBox("Login","Enter your name:","John Generic")
The password char parameter replaces all inputed characters with the first value. Placing a whitespace in the first character position will cause input to be shown as normal. Subsequent characters are used to restrict and enforce input.
- M = Mandatory entry before continuing
- n = Only n characters may be entered where n is an integer
; Require input no larger than 5 characters in length, replace input with "*" $str = InputBox("Password Check","Please enter your password:","noobs","*M5")
Width & Height
As mentioned above, width and height must be defined together. The size is determined by pixels with a minimum size of 190x115 and a default size of 250x190 however the box is resizable by the user.
$str = InputBox("Size Counts","Resize me!","","",190,115)
Left & Top
Like width and height, left and top must be defined together. The position of the box is measured in pixels from the leftmost position on the screen to the topmost. Thus the upper left hand corner of your screen would be at coordinates (0,0). By default the input box is centered but is also movable by the user.
$str = InputBox("Move Me","Move me!","","",-1,-1,0,0) ; top left corner of the screen
The timeout parameter acts to close the InputBox after x number of seconds have passed.
$str = InputBox("Type Fast","What's 6 x 7?","","",-1,-1,Default,Default,3) ; box will close in 3 seconds
If the InputBox times out before a choice is made a 2 is returned.
Success: Returns input string and sets @Error
Failure: Returns empty string and sets @Error
|1||Cancel button pressed|
|3||InputBox failed to open properly|
$str = InputBox("Try It","Do Something!","stuff","",10) MsgBox(0,"Bada Bing",@error & " " & $str)