Re: Offtopic: simulating a keystroke

fb (fb@chibacity.com)
Fri, 8 Aug 1997 12:07:46 -0500 (EST)


Woohoo, this may work... I'm not sure though because I think many games
access they keyboard and read the 'make' or 'break' scan codes instead of
chars but I will try this

Thanks
fb
fb@chibacity.com


On Fri, 8 Aug 1997, Malcolm Beattie wrote:

> fb writes:
> > Ok, now here's the tricky part :) How should I go about simulating a
> > keystroke in a way that it will be transparent to all applications? (ie
> > the program that recieves the key press will not know that its a simulated
> > one)
>
> User-mode, not kernel.
> #include <sys/ioctl.h>
> char ch;
> ioctl(fd, TIOCSTI, &ch);
> forces character ch into the input buffer provided fd refers to your
> controlling terimnal (or your privileged). Quick example:
>
> #include <sys/ioctl.h>
> int main(void) {
> ioctl(1, TIOCSTI, "l");
> ioctl(1, TIOCSTI, "s");
> ioctl(1, TIOCSTI, "\n");
> return 0;
> }
>
> --Malcolm
>
> --
> Malcolm Beattie <mbeattie@sable.ox.ac.uk>
> Unix Systems Programmer
> Oxford University Computing Services
>