Simulate input/Keyboard: Difference between revisions

Content added Content deleted
No edit summary
Line 1: Line 1:
{{task|GUI}}[[Category:Testing]]{{Omit From|Modula-3}}
{{task|GUI}}[[Category:Testing]]
{{omit from|ACL2}}
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|Batch File}}
{{omit from|Brainf***}}
{{omit from|Maxima}}
{{Omit From|Modula-3}}
{{omit from|PARI/GP}}
{{omit from|PHP}}
{{omit from|PostScript}}
{{omit from|R}}
{{omit from|Retro}}
{{omit from|TI-83 BASIC}} {{omit from|TI-89 BASIC}}
{{omit from|zkl}

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" and displays that in "message 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}}==
[[Category:Scala Implementations]]{{libheader|Scala}}<lang scala>import java.awt.Robot
{{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; it sends a single key "x" to the given window.
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]] illustrates a very closely related method.
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>

{{omit from|ACL2}}
{{omit from|Batch File}}
{{omit from|Brainf***}}
{{omit from|Maxima}}
{{omit from|PARI/GP}}
{{omit from|PHP}}
{{omit from|PostScript}}
{{omit from|R}}
{{omit from|Retro}}
{{omit from|TI-83 BASIC}} {{omit from|TI-89 BASIC}}
{{omit from|zkl}