Is there any way to simulate a keypress in Linux using C?
In my specific situation, I\'m on Ubuntu 9.04 and need a simple app that invokes a press on the \"pause\" b
There's a programmable library called 'xdotool':
sudo apt-get install libxdo-dev libxdo2
cat test.c
#include
#include
#include
#include
int main() {
xdo_t * x = xdo_new(":0.0");
while(1) {
printf("simulating Shift_L keypress\n");
xdo_keysequence(x, CURRENTWINDOW, "Shift_L", 0);
sleep(5);
}
return 0;
}
Run like this:
gcc test.c -lxdo -o test