我有一个AutoHotkey脚本,需要从用户那里读取多行员工数据。
InputBox, userInput, Employee Records, Please enter employee records. (One per line)
不幸的是,InputBox仅允许用户输入单行文本。尝试使用 Enter 添加换行符将改为提交已输入的数据。
如何在AutoHotkey脚本中接收多行用户输入?
答案 0 :(得分:2)
这演示了一个多行输入框
F2::
Gui, Add, Text,, Please enter employee records (One per line):
Gui, Add, Edit, w600 h60 vinput
Gui, Add, Button, gokay_pressed, Okay
Gui, Add, Button, cancel X+8 YP+0, Cancel
Gui, Show, Center autosize, Employee Records
Return
okay_pressed:
Gui Submit
Gui Destroy
MsgBox %input%
Return
GuiClose:
GuiEscape:
ButtonCancel:
Gui, Destroy
return
答案 1 :(得分:2)
这实现了通用的多行输入功能
F3::MsgBox % MultiLineInput( "Employee Records", "Please enter employee records (One per line):" )
MultiLineInput(title, prompt)
{
static input
input := ""
Gui, Add, Text,, %prompt%
Gui, Add, Edit, w400 h60 vinput
Gui, Add, Button, gokay_pressed, Okay
Gui, Add, Button, cancel X+8 YP+0, Cancel
Gui, Show, Center autosize, %title%
WinWaitClose %title%
return input
okay_pressed:
Gui Submit
Gui Destroy
return
GuiClose:
GuiEscape:
ButtonCancel:
Gui, Destroy
return
}