Send KeyPress/KeyRelease event to window
Andre Couturier
ac at ac13.de
Fri Mar 5 00:00:10 PST 2010
Hi,
I try to send a key event to a window with input fields, I use the code
example from http://www.codase.com/search/call?name=xsendevent and change
the InputFocus oft the window handle. But my code only works if the
destination window is the one with focus. It this possible?
xkp.type = KeyPress;
xkp.xkey.type = KeyPress;
xkp.xkey.display = display;
xkp.xkey.serial = 0L;
xkp.xkey.send_event = True;
xkp.xkey.display = display;
xkp.xkey.x = xkp.xkey.y = xkp.xkey.x_root = xkp.xkey.y_root = 0;
xkp.xkey.time = get_time();
xkp.xkey.same_screen = True;
xkp.xkey.subwindow = None;
xkp.xkey.window = twin;
xkp.xkey.root = DefaultRootWindow(display);
xkp.xkey.keycode = XKeysymToKeycode(display, keysym);
xkp.xkey.state = (f_shift ? ShiftMask : 0) |
(f_control ? ControlMask : 0) |
(f_alt ? Mod1Mask : 0);
XSendEvent(display, twin, True, KeyPressMask, (XEvent *)&xkp);
xkp.xkey.type = KeyRelease;
xkp.xkey.time = get_time();
XSendEvent(display, twin, True, KeyReleaseMask, (XEvent *)&xkp);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20100305/187d5334/attachment.html>
More information about the xorg
mailing list