如何获取窗口标题中含某种特征字符串的窗口句柄

isfay 2010-01-19 10:46:20
比如傲游浏览器窗口标题中总含有“傲游”二字,类似的,如果想找别的有某种特征字符串的窗口,如何找?
找具体的标题可用FindWindow,但这种标题不唯一的如何找?有没有什么较为简便的办法?
自己搜了搜,没有发现很好的解决方案,特向各位高手请教。

...全文
171 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
WizardK 2010-01-20
  • 打赏
  • 举报
回复
枚举所有窗口,检测窗口名称,没有简便的方法。
老邓 2010-01-20
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 isfay 的回复:]
“使用窗口类名称查找,比查找标题要快些”这个具体用哪个函数实现?首先还是要求速度快,比如二十几个窗口能在两三秒内找到特定窗口,机器配置不错,内存4G。如果速度快还能简便点当然更好
[/Quote]
还是FindWindow

FindWindow Function

The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.

To search child windows, beginning with a specified child window, use the FindWindowEx function.

Syntax


HWND FindWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName
);
Parameters

lpClassName
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.

If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.

lpWindowName
[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.
Return Value

isfay 2010-01-20
  • 打赏
  • 举报
回复
“使用窗口类名称查找,比查找标题要快些”这个具体用哪个函数实现?首先还是要求速度快,比如二十几个窗口能在两三秒内找到特定窗口,机器配置不错,内存4G。如果速度快还能简便点当然更好
jsit123 2010-01-20
  • 打赏
  • 举报
回复
ding...
isfay 2010-01-20
  • 打赏
  • 举报
回复
这样啊,那就结帖给分!
0x826 2010-01-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zyq5945 的回复:]
EnumWindows枚举出所有窗口,自己再判断查看标题是否带有指定字符即可
[/Quote]

就用这个就可以 先枚举出来 再判断字符串中是否存在需要比对的信息
老邓 2010-01-19
  • 打赏
  • 举报
回复
使用窗口类名称查找,比查找标题要快些。
isfay 2010-01-19
  • 打赏
  • 举报
回复
还有别的办法么?更简便的?
zyq5945 2010-01-19
  • 打赏
  • 举报
回复
EnumWindows枚举出所有窗口,自己再判断查看标题是否带有指定字符即可
isfay 2010-01-19
  • 打赏
  • 举报
回复
自己顶一个!

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧