How do you simulate the use of the keyboard ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goFreeLoop
    New Member
    • Sep 2010
    • 1

    How do you simulate the use of the keyboard ?

    In my script, I would like to simulate the fact that someone presses on the "x" key on the keyboard and then presses Return.
    I got some info from web, but still confused
    Code:
    #!/usr/bin/perl -w
    require 'sys/ioctl.ph';
    die "no TIOCSTI" unless defined &TIOCSTI;
    sub jam {    
    local $SIG{TTOU} = "IGNORE"; # "Stopped for tty output"    local *TTY;  # make local filehandle    open(TTY, ">/dev/tty")                 or die "no tty: $!";    for (split(//, $_[0])) {        ioctl(TTY, &TIOCSTI, $_)            or die "bad TIOCSTI: $!";    }    
    close(TTY);}
    jam("@ARGV\n");

    If anyone knows how to do that or if it is even possible to do it. Cheers !
    Last edited by Niheel; Sep 17 '10, 03:09 AM.
Working...