获取任务栏中所有窗口的句柄

发布于 2024-10-07 03:38:14 字数 561 浏览 7 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甲如呢乙后呢 2024-10-14 03:38:14

您看到 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.

鸵鸟症 2024-10-14 03:38:14

确切的算法没有记录,我在 这个答案做得很好。

The exact algorithm is not documented, I came up with some pseudo code in this answer that does an ok job.

热鲨 2024-10-14 03:38:14

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文