InputBox: Difference between revisions
m (→Left & Top) |
m (→Syntax) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
=Syntax= | =Syntax= | ||
<syntaxhighlight lang="autoit"> | |||
InputBox("title","prompt"[,"default"[,"password char[Option]"[,width[,height[,left,top[,timeout[,hwnd]]]]]]) | |||
</syntaxhighlight> | |||
=Parameters= | =Parameters= | ||
Line 22: | Line 24: | ||
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. | 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. | ||
<syntaxhighlight lang="autoit"> | |||
Local $str = InputBox("Login","Enter your name:","John Generic") | |||
</syntaxhighlight> | |||
=Password Character= | =Password Character= | ||
Line 31: | Line 35: | ||
; Require input no larger than 5 characters in length, replace input with "*" | ; Require input no larger than 5 characters in length, replace input with "*" | ||
<syntaxhighlight lang="autoit"> | |||
Local $str = InputBox("Password Check","Please enter your password:","noobs","*M5") | |||
</syntaxhighlight> | |||
=Width & Height= | =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. | 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. | ||
<syntaxhighlight lang="autoit"> | |||
Local $str = InputBox("Size Counts","Resize me!","","",190,115) | |||
</syntaxhighlight> | |||
=Left & Top= | =Left & Top= | ||
Line 47: | Line 55: | ||
=Timeout= | =Timeout= | ||
The timeout parameter acts to close the InputBox after ''x'' number of seconds have passed. | The timeout parameter acts to close the InputBox after ''x'' number of seconds have passed. | ||
<syntaxhighlight lang="autoit"> | |||
Local $str = InputBox("Type Fast","What's 6 x 7?","","",-1,-1,Default,Default,3) ; box will close in 3 seconds | |||
</syntaxhighlight> | |||
If the InputBox times out before a choice is made a 2 is returned. | If the InputBox times out before a choice is made a 2 is returned. | ||
Line 64: | Line 72: | ||
</table> | </table> | ||
<syntaxhighlight lang="autoit"> | |||
Local $str = InputBox("Try It","Do Something!","stuff","",10) | |||
MsgBox(0,"Bada Bing",@error & " " & $str) | |||
</syntaxhighlight> | |||
[[Category:GUI]] | [[Category:GUI]] |
Latest revision as of 09:19, 4 November 2017
InputBox displays a popup box prompting the user to enter a string. Adapted from AutoIt doc.
Syntax
InputBox("title","prompt"[,"default"[,"password char[Option]"[,width[,height[,left,top[,timeout[,hwnd]]]]]])
Parameters
Param | Purpose |
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.
Local $str = InputBox("Login","Enter your name:","John Generic")
Password Character
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.
- Options
- 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 "*"
Local $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.
Local $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.
Local $str = InputBox("Move Me","Move me!","","",-1,-1,0,0) ; top left corner of the screen
Timeout
The timeout parameter acts to close the InputBox after x number of seconds have passed.
Local $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.
Return Values
Success: Returns input string and sets @Error
Failure: Returns empty string and sets @Error
Error Code | Reason |
0 | Successful execution |
1 | Cancel button pressed |
2 | Timeout occurred |
3 | InputBox failed to open properly |
Local $str = InputBox("Try It","Do Something!","stuff","",10)
MsgBox(0,"Bada Bing",@error & " " & $str)