获取任务栏中所有窗口的句柄
我对 Windows API 很陌生,我正在尝试查找任务栏中出现的所有窗口的句柄。
到目前为止,我已经设法:
- 获取所有窗口的句柄
- 获取窗口的标题
- 检查窗口是否可见
- 检查窗口是否存在
- 最小化窗口
- 获取窗口的子窗口
- 获取桌面窗口
我已尝试获取所有窗口桌面窗口的子窗口,这给了我近 900 个窗口句柄!所以我试图通过仅获取可见窗口和标题长度超过 0 个字符的窗口来过滤它们,但我仍然很遥远 - 有 68 个窗口?
那么,一些 Win API 专家能否告诉我如何执行此操作:-)
,并可能解释一下为什么有这么多窗口?
编辑:
private static bool HasAppWindowStyle(IntPtr handle)
{
return (GetWindowLong(handle, GWL_EXSTYLE) & WS_EX_APPWINDOW) != 0;
}
I'm quite new to the Windows API and I'm trying to find the handles of all the windows which appear in the taskbar.
So far, I have managed to:
- Get the handles of all windows
- Get the title of a window
- Check whether a window is visible
- Check whether a window exists
- Minimise a window
- Get the child windows of a window
- Get the desktop window
I have tried getting all child windows of the desktop window, which gives me nearly 900 window handles! So I tried to filter them down, by getting only visible windows and only windows whose title is longer than 0 characters, but I'm still way off - with 68 windows??
So could some Win API expert enlighten me as to how you do this please :-)
and also possibly explain why there are so many windows?
Edit:
private static bool HasAppWindowStyle(IntPtr handle)
{
return (GetWindowLong(handle, GWL_EXSTYLE) & WS_EX_APPWINDOW) != 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您看到 FindWindowEx 示例了吗?您也可以过滤它们以在其上显示文本,我认为您看到的窗口是 Destop 项目(我不确定),但从桌面上删除一些项目并查看更改。
Did you see FindWindowEx sample? Also you can filter them to have a text on it, I think the windows you are see is the Desctop items (I'm not sure) but remove some item from desktop and see the changes.
确切的算法没有记录,我在 这个答案做得很好。
The exact algorithm is not documented, I came up with some pseudo code in this answer that does an ok job.
使用 EnumWindows 找到并具有任务栏按钮的顶级窗口将打开 WS_VISIBLE 和 WS_EX_APPWINDOW 样式标志。
Top-level windows that you find with EnumWindows and have taskbar buttons will have the WS_VISIBLE and WS_EX_APPWINDOW style flags turned on.