Simulate input/Keyboard

From Rosetta Code
Revision as of 14:14, 2 June 2009 by rosettacode>Dkf (→‎Tcl: Added implementation)
Task
Simulate input/Keyboard
You are encouraged to solve this task according to the task description, using any language you may know.

send simulated keystrokes to a gui window (specify if the target may be externally created).

AutoHotkey

target may be externally created. <lang AutoHotkey> run, cmd /k WinWait, ahk_class ConsoleWindowClass controlsend, ,hello console, ahk_class ConsoleWindowClass </lang>

Tcl

Library: Tk


This only works with windows created by Tk; it sends a single key “x” to the given window. <lang tcl>event generate $target <Key-x></lang> To send multiple keys, call repeatedly in order.