我正在使用 ubuntu。在终端中通过窗口名称获取窗口 ID 的命令是
xdotool search --name "窗口名称"
但我想使用 C++ 程序获得相同的结果。
最佳答案
引用资料:
Sending Keystrokes to a X Window
我无法自己编译和检查,但我认为这是按名称搜索窗口的最少代码。
#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/