InputBox
显示用户数据输入框.
InputBox ( "title", "prompt" [, "default" [, "password char" [, width = -1 [, height = -1 [, left = Default [, top = Default [, timeout = 0 [, hwnd]]]]]]]] )
参数
title
|
输入框的标题文字.
|
prompt
|
提示输入数据的类型, 意义.
|
default
|
[可选] 输入框初始显示的默认值.
|
password char
|
[可选] 替换所有输入字符的显示字符. 默认为空("")或设置第一个字符为空格, 使输入字符原样显示.
如果此参数被设为多字符, 则只有第一个字符用于替换输入字符.
第二个字符及后面的其它字符有其它特殊用途. 见备注.
|
width
|
[可选] 窗口宽度.
|
height
|
[可选] 窗口高度.
|
left
|
[可选] 输入框的左边距离. default(默认) = 居中显示.
|
top
|
[可选] 输入框的上边距离. default(默认) = 居中显示.
|
timeout
|
[可选] 输入框自动关闭的延迟时间(秒).
|
hwnd
|
[可选] 输入框的父窗口句柄.
|
返回值
成功:
|
返回已输入的字符串.
|
失败:
|
返回 "" (空字符串). @error 设置为非 0 值:
|
@error:
|
1 = 取消按钮被点击.
2 = 已超时.
3 = 输入框显示失败, 通常由于参数无效.
4 = 输入框无法显示在任何监视器上.
5 = (宽度, 高度, 左距, 顶距)参数无效.
|
备注
可以调整输入框的窗口大小,但最小尺寸限制大约为: 190 x 115(象素), 默认的大小大约为: 250 x 190 (象素).
返回的字符串将不超过 254 个字符, 如果输入包含回车或换行符, 返回的字符串将被第一个回车或换行符断开.
参数"密码"的第二个及后续字符可以用于限制用户输入.
如果第一个字符是空格, 则输入字符将原样显示.
若第二个字符是 M 则表示输入将是强制性的; 即你必须输入内容.
如果在没有输入任何内容的情况下按下[确定]按钮, 则脚本不会有任何反应, 输入框既不会消失也不会返回字符串.
可以在"密码字符"参数的后面加上一个数字以指定输入字符串的最大长度.
函数示例
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Places the input box in the top left corner displaying the characters as they
; are typed.
Local $sAnswer = InputBox("Question", "Where were you born?", "Planet Earth", "", _
- 1, -1, 0, 0)
; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $sAnswer)
; Asks the user to enter a password. Don't forget to validate it!
Local $sPasswd = InputBox("Security Check", "Enter your password.", "", "*")
; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $sPasswd)
; Asks the user to enter a 1 or 2 character response. The M in the password
; field indicates that empty string is not accepted and the 2 indicates that the
; responce will be at most 2 characters long.
Local $sValue = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2")
; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $sValue)
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令调用 exect
参见:
MsgBox
exect=$var_vbutton=InputBox('Вопрос','其中~~вы~~род或сь?') GLOBALEXECT<a> ;; 信息输入窗口示例
exect=$var_vbutton=InputBox('Вопрос','其中~~вы~~род或сь?')||$var_input=MsgBox(4096,'Сообщение','$var_button') GLOBALEXECT<a> ;; 消息窗口中输出信息的输入窗口示例
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|