Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Answer: How do you simulate the use of the keyboard ?

by merlyn (Sage)
on May 11, 2000 at 01:05 UTC ( #11058=categorized answer: print w/replies, xml ) Need Help??

Q&A > input and output > How do you simulate the use of the keyboard ? - Answer contributed by merlyn

Depends on what you mean by "simulate". One way to mean it is to force a "y\n" into your own tty input buffer, like so:
sub jam { $TIOCSTI = 0x80017472; for (split(//, $_[0])) { ioctl(STDERR, $TIOCSTI, $_) || die "bad TIOCSTI: $!"; } } jam("y\n");
Note that the value of TIOCSTI can be had from some "use something" that escapes me at the moment, but it'll end up looking like this pretty close.

Replies are listed 'Best First'.
Re: Answer: How do you simulate the use of the keyboard ?
by Anonymous Monk on Sep 25, 2003 at 12:00 UTC
    I have the above working for ordinary input (i.e. ascii codes) but how could i simluate the use of arrows keys, for example in vi? These do not have a proper ascii code. Duncs
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2016-09-26 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (475 votes). Check out past polls.