Emulate keyboard in C in Linux
Posted on 2007-10-04
I know a fair bit about linux, but I'm a bit of a C newbie. I know C up to about a 2nd year university level.... so... not a whole heck of a lot ^^; but enough to know how it works.
I've been asked to write a piece of software for a linux machine, which will run in parallel with another graphical application (so.. run in its own thread?) which is running full-screen. I want the C program to pause for a minute or so, then output some keystrokes in such a way that the other program that is running in full screen will receive them.
In windows it's easy, there's an API function called keybd_event() you can use for just that. But... to do it on linux I'm a little lost.
I will be executing this program from a shell script just prior to the full screen application loading. So when I run it I could probably put "&" at the end to signify that it runs in its own thread, unless of course I'm missing something.
As for the linux system, it is a very stripped down linux system. It does not have a desktop environment, and when it boots there is no "user" login. It just logs in as root and goes. There may not be much in the way of addon software or modules to work with on the system.