查找特殊窗口 - FindWindowSuper
函数简介
根据多种条件组合查找特定窗口,支持两个条件的组合查询。
接口名称
FindWindowSuper
DLL调用
long FindWindowSuper(long ola, string spec1, int flag1, int type1, string spec2, int flag2, int type2);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| spec1 | 字符串 | 查找条件1的内容,具体含义由flag1决定。 |
| flag1 | 整数型 | 查找条件1的类型,详见下方说明。 |
| type1 | 整数型 | 查找条件1的匹配方式:0 精确匹配,1 模糊匹配。 |
| spec2 | 字符串 | 查找条件2的内容,具体含义由flag2决定。 |
| flag2 | 整数型 | 查找条件2的类型,取值同flag1。 |
| type2 | 整数型 | 查找条件2的匹配方式:0 精确匹配,1 模糊匹配。 |
flag 查找条件类型
| 值 | 说明 |
|---|---|
| 0 | 窗口标题。 |
| 1 | 程序名(如notepad)。 |
| 2 | 窗口类名。 |
| 3 | 程序路径(不含盘符,如\windows\system32)。 |
| 4 | 父窗口句柄(十进制字符串)。 |
| 5 | 父窗口标题。 |
| 6 | 父窗口类名。 |
| 7 | 顶级窗口句柄(十进制字符串)。 |
| 8 | 顶级窗口标题。 |
| 9 | 顶级窗口类名。 |
示例
// 查找标题包含"记事本"且类名为"Notepad"的窗口
long hwnd = FindWindowSuper(instance, "记事本", 0, 1, "Notepad", 2, 0);
if (hwnd != 0) {
printf("找到窗口,句柄: %ld\n", hwnd);
}
返回值
长整数型:找到的窗口句柄。未找到返回 0。
注意事项
- 两个条件必须同时满足才会返回窗口句柄。
