如何在AutoIt中输入键盘输入?

时间:2009-08-19 08:20:51

标签: autoit

我想在AutoIt中编写一个脚本,它可以从键盘上自动输入,比方说A-Z,无需用户干预。

这可能吗?

2 个答案:

答案 0 :(得分:4)

您的程序不太可能需要捕获所有键的所有输入。如果你确实需要那种用户输入AutoIt可能不适合你 - 请参阅the post from the author of AutoIt about keyloggers。如果您需要输入热键类型的键盘输入:在AutoIt中执行此操作非常简单。

HotKeySet("^+{q}", "reactionFunction")

While 1
    ; A loop
WEnd

Func reactionFunction()
    MsgBox(0, "You pressed CTRL+Shift+q", "You pressed CTRL+Shift+q")
    Exit
EndFunc

如果你想从一个非常简单的输入框中获取用户输入。

$data = InputBox("Enter Something", "Enter some data in the field below.")
MsgBox(0, "The String You Entered...", "The string you entered is... " & $data)

有关HotKeySet和InputBox的更多信息可以在the AutoIt.chm help file中找到(它实际上是一个很好的参考)。

答案 1 :(得分:2)

我不确定我是否理解您的问题 - 您希望模拟按键而不会有人实际使用键盘?如果是这样,那就是AutoIt中的the send command

您想让真实用户向脚本提交输入吗?这就是the GUI in AutoIt的用途。