gpt4 book ai didi

c++ - 如何在 ubuntu 中使用 C++ 程序获取窗口的窗口 ID?

转载 作者:行者123 更新时间:2023-11-28 03:04:46 28 4
gpt4 key购买 nike

我正在使用 ubuntu。在终端中通过窗口名称获取窗口 ID 的命令是

xdotool search --name "窗口名称"

但我想使用 C++ 程序获得相同的结果。

最佳答案

引用资料:

Sending Keystrokes to a X Window

Github

我无法自己编译和检查,但我认为这是按名称搜索窗口的最少代码。

#include <xdo.h>

Window *list;
xdo_search_t search;
unsigned int nwindows;
memset(&search, 0, sizeof(xdo_search_t));
search.max_depth = -1;
search.require = xdo_search::SEARCH_ANY;

search.searchmask |= SEARCH_NAME;
search.winname = "enter name here";

// the context
xdo_t* p_xdo = xdo_new(NULL);
int id = xdo_window_search(p_xdo, &search, &list, &nwindows);

关于c++ - 如何在 ubuntu 中使用 C++ 程序获取窗口的窗口 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20015099/

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