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

标签 c++ ubuntu

我正在使用 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/

相关文章:

python-3.x - 激活python virtualenv后如何自动运行shell脚本?

c++ - libxrandr 库 : how to change properties of connected monitors?

c++ - 使用 getline c++ 将数据存储在 vector 中

c++ - 警告 C26812 : Enum type is unscoped. 优先选择枚举类而不是枚举

c++ - C/C++ 中的可变参数函数和参数赋值

ubuntu - Nginx hsts 选项禁用其他安全性

linux - gitolite 包不创建用户

mysql - 由于外键约束,无法在 ubuntu/trusty64 php5-mysql 上创建表

c++ - 将 mem_fun 与具有多个参数的函数一起使用

c++ - signed/unsigned int 转换发生了什么?