如何在AutoHotkey中读取多行用户输入?

时间:2017-08-31 16:34:08

标签: user-input autohotkey

我有一个AutoHotkey脚本,需要从用户那里读取多行员工数据。

InputBox, userInput, Employee Records, Please enter employee records. (One per line)

不幸的是,InputBox仅允许用户输入单行文本。尝试使用 Enter 添加换行符将改为提交已输入的数据。

如何在AutoHotkey脚本中接收多行用户输入?

user input

2 个答案:

答案 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

enter image description here

答案 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
}