I'm trying to send key events to a display event if it is not in the foreground.
At the moment i'm doing the following:
Display *d_;
d_ = XOpenDisplay(NULL);
system(QString("xdotool key Shift+F8").toStdString().c_str());
XFlush(d_);
XCloseDisplay(d_);
Though this is not working when the display is not focused.
So my questions are:
- How can I send the key event to the display when it's not focused.
- Is there a nicer way for sending a keystroke than starting a tool via shell?
- Why do I have to open a new Display before using the shell command?
I'm using Qt and the code should run on Linux.