gpt4 book ai didi

c - 在 linux 中,获取窗口类 raise "X Error of failed request: BadWindow (invalid Window parameter)"

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:07:56 25 4
gpt4 key购买 nike

这是我的代码,我得到“请求失败的 X 错误:BadWindow(无效的 Window 参数)”

xdo_t *xdo = xdo_new(":0");
XWindowAttributes attr;
XClassHint classhint;
Window window;
XGetWindowAttributes(xdo->xdpy, window, &attr);
if (XGetClassHint(xdo->xdpy, window, &classhint)) {
classhint.res_name;
}

最佳答案

我找到了解决方案,错误消息显示“(无效的窗口参数)”,这意味着我应该首先获取窗口,在我的例子中 62914561 是 google-chrome 窗口 ID(我通过 xdotool search google- chrome), 下面的代码应该可以工作

#include <X11/Xutil.h>
#include <xdo.h>

int main(int argc, char **argv) {
Display *display = XOpenDisplay(NULL);
XWindowAttributes attr;
XClassHint classhint;
Window window = 62914561;
XGetWindowAttributes(display, window, &attr);

if (XGetClassHint(display, window, &classhint)) {
classhint.res_name;
}
}

关于c - 在 linux 中,获取窗口类 raise "X Error of failed request: BadWindow (invalid Window parameter)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34704542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com