Hick
Hick

Reputation: 36394

How do I take keyboard input in AutoIt?

I want to write a script in AutoIt, which can take automatic input from the keyboard, let's say A-Z, without user intervention.

Is this possible?

Upvotes: 2

Views: 24984

Answers (2)

Copas
Copas

Reputation: 5952

It is unlikely that your program needs to capture all input from all keys. If you do in fact need that kind of user input AutoIt might not be for you - see the post from the author of AutoIt about keyloggers. If you need to take keyboard input of the hotkey type: doing that in AutoIt is super easy.

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

While 1
    ; A loop
WEnd

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

If you want to take user input from an input box that is really easy also.

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

More information about HotKeySet and InputBox can be found in the AutoIt.chm help file (it's actually a great reference).

Upvotes: 4

Mark Rushakoff
Mark Rushakoff

Reputation: 258138

Not sure I understand your question - you want to simulate keypresses without someone actually using the keyboard? If so, that's the send command in AutoIt.

You want to let a real user submit input to the script? That's what the GUI in AutoIt is for.

Upvotes: 2

Related Questions