I'm trying to write a C program that will send keypresses to kuickshow. For example, the "M" key, or the "Page_Down" key. I'm using KDE 3.3.2 (debian stable) It seems like I'm almost there, but I have one more hump to get over.
- It works if kuickshow has FOCUS.
- It works perfectly with gaim, even when gaim does not have focus.
- kuickshow will work without focus IF the Ctrl key is included (event.state = ControlMask)
But... I can't seem to get kuickshow to respond to a plain Page_Down key without window focus. (Of course, I could make new shortcuts that have the control key included, but that's kind of a hack. I'd like to get this working properly!)
Here's some C code:
PHP Code:
#define XK_LATIN1
#define XK_MISCELLANY
#include <X11/keysymdef.h>
#include <X11/Xlib.h>
Display *disp;
XKeyEvent kp;
void press_key()
{
kp.type = KeyPress;
XSendEvent (disp, kp.window, False, KeyPressMask, (XEvent *)(&kp));
}
int main()
{
disp = XOpenDisplay(NULL);
kp.window = 0x3200d1b;
kp.state = ControlMask;
kp.keycode = XKeysymToKeycode (disp, XK_Page_Down);
press_key();
XCloseDisplay(disp);
}
So this works, but I want the kp.state to be 0 instead of ControlMask.
I've tried specifying all sorts of variables, like kp.display, or the time; I've tried including a KeyRelease, after the KeyPress; I've tried switching the propagate bool (3rd var in XSendEvent call) to True and False, etc.
A hint to others: to get that window ID (0x3200d1b) use xwininfo
Any bright ideas?
Too bad DCOP doesn't seem to offer functionality to fully control the app. Maybe later.