鱼C论坛

 找回密码
 立即注册
查看: 1512|回复: 7

[已解决]如何读取没有标题栏和窗口名的窗口句柄。

[复制链接]
发表于 2017-6-13 18:25:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
捕获.PNG

这样的窗口怎么读取句柄?用enumwindow可以枚举出来(在结果里一个一个的对着找的),但是怎么判断是不是自己要找的窗口的句柄?
最佳答案
2017-6-20 20:35:26
通过Button的句柄调用GetParent获取主窗口的句柄 .
不一定能成功
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2017-6-16 21:25:36 | 显示全部楼层
up
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2017-6-19 17:03:19 | 显示全部楼层
upup
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-6-20 19:48:40 | 显示全部楼层
子窗口控件也是有标题的 . 这个的ClassName应该是 "Button" .

尝试用一下
HWND FindWindowEx(
  HWND hwndParent,      // handle to parent window
  HWND hwndChildAfter,  // handle to a child window
  LPCTSTR lpszClass,    // pointer to class name
  LPCTSTR lpszWindow    // pointer to window name
);
 
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-6-20 20:00:15 | 显示全部楼层
俞晨曦 发表于 2017-6-20 19:48
子窗口控件也是有标题的 . 这个的ClassName应该是 "Button" .

尝试用一下

我是要找窗口句柄,而不是BUTTON控件的句柄。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-6-20 20:33:49 | 显示全部楼层
GetParent
The GetParent function retrieves a handle to the specified child window's parent window.

HWND GetParent(
  HWND hWnd   // handle to child window
);

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-6-20 20:35:26 | 显示全部楼层    本楼为最佳答案   
通过Button的句柄调用GetParent获取主窗口的句柄 .
不一定能成功
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-6-21 13:48:22 | 显示全部楼层
#include <stdio.h>
#include <Windows.h>

BOOL CALLBACK EnumWindowsProc(
        _In_ HWND   hwnd,
        _In_ LPARAM lParam
)
{
        HWND hwnd1;
        hwnd1 = FindWindowExA(hwnd, 0, "Button", "Close");        
        if (hwnd1)
        {
                printf("当前枚举句柄:%x\t控件句柄:%x\t父窗口句柄:%x\n", hwnd, hwnd1, GetParent(hwnd1));
        }
        return 1;        
}

int main()
{
        EnumWindows(EnumWindowsProc, NULL);
        return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-3 17:45

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表