Simulate input/Keyboard: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 357: Line 357:
Compile and run it by (assuming we have GNU C compiler):
Compile and run it by (assuming we have GNU C compiler):
<pre>nim c -r ourfile.nim</pre>
<pre>nim c -r ourfile.nim</pre>

=={{header|OCaml}}==
=={{header|OCaml}}==


Line 492: Line 493:


This only works with internal windows.
This only works with internal windows.



=={{header|Perl}}==
=={{header|Perl}}==
Line 518: Line 518:


<lang perl>SendKeys("Hello, how are you?\n");</lang>
<lang perl>SendKeys("Hello, how are you?\n");</lang>

=={{header|Perl 6}}==
{{works with|Rakudo|2018.12}}
Use libxdo bindings to send text / keystrokes to any application that will accept keystrokes from X11.

<lang perl6>use X11::libxdo;

my $xdo = Xdo.new;

my $active = $xdo.get-active-window;

my $command = $*VM.config<os> eq 'darwin' ?? 'open' !! 'xdg-open';

shell "$command https://www.google.com";

sleep 1;

my $match = rx[^'Google -'];

say my $w = $xdo.search(:name($match))<ID>;

sleep .25;

if $w {
$xdo.activate-window($w);
say "Window name: ", $xdo.get-window-name( $w );
$xdo.type($w, 'Perl 6');
sleep .25;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Return');
}</lang>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
Line 631: Line 595:
>>> pyautogui.keyUp('shift') # release the shift key
>>> pyautogui.keyUp('shift') # release the shift key
>>> pyautogui.hotkey('ctrl', 'shift', 'esc')</lang>
>>> pyautogui.hotkey('ctrl', 'shift', 'esc')</lang>



=={{header|Racket}}==
=={{header|Racket}}==
Line 658: Line 621:
(send canvas simulate-key (new key-event% (key-code #\k))) ; Sends the simulated key press (with a key-event% instance)
(send canvas simulate-key (new key-event% (key-code #\k))) ; Sends the simulated key press (with a key-event% instance)
;outputs k</lang>
;outputs k</lang>

=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2018.12}}
Use libxdo bindings to send text / keystrokes to any application that will accept keystrokes from X11.

<lang perl6>use X11::libxdo;

my $xdo = Xdo.new;

my $active = $xdo.get-active-window;

my $command = $*VM.config<os> eq 'darwin' ?? 'open' !! 'xdg-open';

shell "$command https://www.google.com";

sleep 1;

my $match = rx[^'Google -'];

say my $w = $xdo.search(:name($match))<ID>;

sleep .25;

if $w {
$xdo.activate-window($w);
say "Window name: ", $xdo.get-window-name( $w );
$xdo.type($w, 'Perl 6');
sleep .25;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Tab');
sleep .5;
$xdo.send-sequence($w, 'Return');
}</lang>


=={{header|REXX}}==
=={{header|REXX}}==
Line 669: Line 669:
/* [↑] text will be available for any program to use (including DOS).*/
/* [↑] text will be available for any program to use (including DOS).*/
/*stick a fork in it, we're all done. */</lang><br><br>
/*stick a fork in it, we're all done. */</lang><br><br>



=={{header|Rust}}==
=={{header|Rust}}==
Line 679: Line 678:
autopilot::key::type_string("Hello, world!", None, None, &[]);
autopilot::key::type_string("Hello, world!", None, None, &[]);
}</lang>
}</lang>

=={{header|Scala}}==
=={{header|Scala}}==
{{libheader|Scala}}
{{libheader|Scala}}