How can I read multiple lines of user input in Aut

2019-05-16 23:02发布

I have an AutoHotkey script which needs to read multiple lines of employee data from a user.

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

Unfortunately, an InputBox only allows users to enter a single line of text. Trying to add newlines with Enter will instead submit whatever data has been entered.

How can I take in multiple lines of user input in an AutoHotkey script?

user input

2条回答
姐就是有狂的资本
2楼-- · 2019-05-16 23:13

This implements a generic multiline input function

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
}
查看更多
Animai°情兽
3楼-- · 2019-05-16 23:14

This demonstrates a multi-line input box

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

查看更多
登录 后发表回答