Jump to content

Simulate input/Keyboard: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 357:
Compile and run it by (assuming we have GNU C compiler):
<pre>nim c -r ourfile.nim</pre>
 
=={{header|OCaml}}==
 
Line 492 ⟶ 493:
 
This only works with internal windows.
 
 
=={{header|Perl}}==
Line 518:
 
<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}}==
Line 631 ⟶ 595:
>>> pyautogui.keyUp('shift') # release the shift key
>>> pyautogui.hotkey('ctrl', 'shift', 'esc')</lang>
 
 
=={{header|Racket}}==
Line 658 ⟶ 621:
(send canvas simulate-key (new key-event% (key-code #\k))) ; Sends the simulated key press (with a key-event% instance)
;outputs k</lang>
 
=={{header|Perl 6Raku}}==
(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}}==
Line 669:
/* [↑] text will be available for any program to use (including DOS).*/
/*stick a fork in it, we're all done. */</lang><br><br>
 
 
=={{header|Rust}}==
Line 679 ⟶ 678:
autopilot::key::type_string("Hello, world!", None, None, &[]);
}</lang>
 
=={{header|Scala}}==
{{libheader|Scala}}
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.