无法使用GetGUIThreadInfo获取窗口标题
Unable to get Window Title using GetGUIThreadInfo
我正在谷歌搜索,发现上面的函数在检索窗口标题文本时更可靠,但它不起作用。我没有得到任何结果;换句话说,没有捕获标题字符串。
GUITHREADINFO gui;
gui.cbSize = sizeof(gui);
char pStr[1024];
GetGUIThreadInfo pGetGUIThreadInfo;
HMODULE hinstUser = LoadLibrary((LPCTSTR) "user32.dll");
pGetGUIThreadInfo = (GetGUIThreadInfo)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "GetGUIThreadInfo");
if (pGetGUIThreadInfo(0 , &gui) == 0)
return NULL;
GetWindowText(gui.hwndFocus, pStr, 1024);
但是上面的代码失败。使用下面的代码
是有效的HWND hwnd = GetForegroundWindow();
GetWindowText(hwnd, pStr, 1024);
我认为如果你使用hwndActive
而不是hwndFocus
,它会达到你想要的效果。
也就是说,我看不出使用GetForegroundWindow()
返回的窗口有什么问题。
相关文章:
- 无法在 GLFW 窗口标题中显示'ä'
- 为什么抓取窗口标题的代码会导致应用崩溃?
- 如何正确获取 Unicode 窗口标题
- 无法获取窗口 C++ 的像素颜色
- 获取窗口中的鼠标位置
- 鼠标输入和键输入有什么区别(在前台获取窗口)
- 获取窗口监视器的唯一标识符
- 使用多个显示器 - XOpenDisplay(NULL) 有时无法获取窗口的当前显示吗?
- 如何随机化程序的窗口标题?
- 如何在QT中获取背景应用程序窗口标题
- 获取窗口任务栏项
- 如何在 Ubuntu Qt 中获取活动窗口标题
- 获取C++中的窗口标题
- 使用WM_GETTEXT获取窗口标题
- 如何从其进程路径中获取窗口标题
- 无法获取窗口标题
- 如何在 Windows 上获取C++ 个字符 * 格式的当前窗口标题?
- 使用窗口标题的一部分获取processID
- 如何在Windows8中获取窗口标题栏(活动和非活动)的颜色
- 无法使用GetGUIThreadInfo获取窗口标题