X11 - Xlib - C:XButtonEvent最小化窗口(铬)

时间:2016-11-11 18:49:43

标签: c++ x11 xlib sendinput

是否有(Xlib,XCB)模拟鼠标单击最小化窗口(在这种情况下为铬)?我试图自动化一些东西,如果窗口在屏幕上的某个地方它可以正常工作(参见下面的代码)。然而,一旦我(有时意外地)最小化它,窗口似乎不再注册XEvents(例如,没有按下网站上的按钮,标签没有刷新......)。遗憾的是没有错误消息。

提前致谢!

.
.
.
XButtonEvent button1EventForSpecificWindow(Display *display, Window rootWindow, Window destWindow, int x,int y, int root_x,int root_y,bool press = true)
{
XButtonEvent click;

// test send event to window
click.display       = display;
click.root          = rootWindow;
click.time          = CurrentTime;
click.same_screen   = True;
click.button        = Button1; // Button 4 mouswheel up!
click.state         = 0;
click.x             = x;
click.y             = y;
click.x_root        = root_x;
click.y_root        = root_y;
click.window        = destWindow;   

if (press)
    click.type = ButtonPress;
else
    click.type = ButtonRelease;

return click;
}
.
.
.
XButtonEvent click1;
XButtonEvent click2;

memset(&click1, 0, sizeof(click1));
memset(&click2, 0, sizeof(click2));

click1 = button1EventForSpecificWindow(display,rootWindow,window_return,dest_x_return,dest_y_return,929,442,true);
click2 = button1EventForSpecificWindow(display,rootWindow,window_return,dest_x_return,dest_y_return,929,442,false);

XSendEvent(click1.display, click1.window, True, ButtonPressMask, (XEvent *)&click1);
XSendEvent(click2.display, click2.window, True, ButtonReleaseMask, (XEvent *)&click2);

XFlush(display); 
.
.
.

0 个答案:

没有答案