0

これが私のコードです。「失敗したリクエストのXエラー:BadWindow(無効なウィンドウパラメーター)」が表示されます

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;
}
4

1 に答える 1

3

エラーメッセージが「(無効なウィンドウパラメーター)」と表示されるため、解決策を見つけました。これは、最初にウィンドウを取得する必要があることを意味します。私の場合、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;
    }
}
于 2016-01-10T11:04:47.093 に答える