我正在尝试在左键按下时移动鼠标指针(Button1)。 但它不起作用。例如,如果我启动GIMP,我会看到一个点(光标向下),然后光标移动但没有绘图。我期待看到一条画线(按住左键的同时移动)。
Display * display = XOpenDisplay(0);
XEvent event;
memset (&event, 0, sizeof (event));
event.xbutton.button = Button1;
event.xbutton.same_screen = True;
event.xbutton.subwindow = DefaultRootWindow (display);
while (event.xbutton.subwindow)
{
event.xbutton.window = event.xbutton.subwindow;
XQueryPointer (display, event.xbutton.window,
&event.xbutton.root, &event.xbutton.subwindow,
&event.xbutton.x_root, &event.xbutton.y_root,
&event.xbutton.x, &event.xbutton.y,
&event.xbutton.state);
}
// Press
event.type = ButtonPress;
if (XSendEvent (display, PointerWindow, True, 0xFFF, &event) == 0)
fprintf (stderr, "Error to send the event!\n");
XFlush (display);
// Move
XWarpPointer(display, None, 0, 0, 0, 0, 0, 50, 50);
XFlush (display);
// Release
event.type = ButtonRelease;
event.xbutton.state = 0x100;
if (XSendEvent (display, PointerWindow, True, 0xFFF, &event) == 0)
fprintf (stderr, "Error to send the event!\n");
XFlush (display);
我做错了什么?
谢谢!
尼古拉斯。