Simulate input/Keyboard: Difference between revisions
Content added Content deleted
No edit summary |
m ({{out}} / -Category:Scala Implementations) |
||
Line 1: | Line 1: | ||
{{task|GUI}}[[Category:Testing]] |
{{task|GUI}}[[Category:Testing]] |
||
⚫ | |||
Send simulated keystrokes to a GUI window, or terminal. You should specify whether the target may be externally created (i.e., if the keystrokes are going to an application other than the application that is creating them). |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{{Omit From|Modula-3}} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Send simulated keystrokes to a GUI window, or terminal. |
|||
You should specify whether the target may be externally created |
|||
(i.e., if the keystrokes are going to an application |
|||
other than the application that is creating them). |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
Line 14: | Line 30: | ||
Send("The answer is 42")</lang> |
Send("The answer is 42")</lang> |
||
It takes user input in variable using "input box" |
It takes user input in variable using "input box" |
||
and displays that in "message box" |
|||
<lang AutoIt>$name="type your name here" |
<lang AutoIt>$name="type your name here" |
||
$name = InputBox("Name","Your name please ?",$name) |
$name = InputBox("Name","Your name please ?",$name) |
||
Line 378: | Line 395: | ||
(prinl (value 8)) # Print the price (12.50) |
(prinl (value 8)) # Print the price (12.50) |
||
(click "logout") # Log out</lang> |
(click "logout") # Log out</lang> |
||
{{out}} |
|||
Output: |
|||
<pre>12.50</pre> |
<pre>12.50</pre> |
||
The same example is used in the related task [[Simulate input/Mouse#PicoLisp]]. |
The same example is used in the related task [[Simulate input/Mouse#PicoLisp]]. |
||
Line 435: | Line 452: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
{{libheader|Scala}} |
|||
<lang scala>import java.awt.Robot |
|||
import java.awt.event.KeyEvent |
import java.awt.event.KeyEvent |
||
Line 465: | Line 483: | ||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
This only works with windows created by Tk; |
This only works with windows created by Tk; |
||
it sends a single key "x" to the given window. |
|||
<lang tcl>set key "x" |
<lang tcl>set key "x" |
||
event generate $target <Key-$key></lang> |
event generate $target <Key-$key></lang> |
||
Line 476: | Line 495: | ||
event generate .t [expr {$c eq " "?"<space>": $c}] |
event generate .t [expr {$c eq " "?"<space>": $c}] |
||
}</lang> |
}</lang> |
||
Note also that the task on [[Keyboard macros#Tcl|keyboard macros]] |
Note also that the task on [[Keyboard macros#Tcl|keyboard macros]] |
||
illustrates a very closely related method. |
|||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
Line 486: | Line 506: | ||
WScript.Sleep 1000 ' one-second delay |
WScript.Sleep 1000 ' one-second delay |
||
WshShell.SendKeys "{Left}{Left}{BkSp}{BkSp}Some text here.~" ' ~ -> Enter</lang> |
WshShell.SendKeys "{Left}{Left}{BkSp}{BkSp}Some text here.~" ' ~ -> Enter</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ |