FindWindow 找不到开始按钮,始终返回 NULL

谁学逆向工程 2019-03-19 04:48:33


	while(true)
{
HWND h = FindWindow(_T("BUTTON"),_T("开始(&S)"));//这里加不加&符号都找不到
if(h!=NULL)
break;
}
...全文
280 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
棉猴 2019-03-21
  • 打赏
  • 举报
回复
引用 5 楼 谁学逆向工程 的回复:
[quote=引用 4 楼 棉猴 的回复:]
MSDN上说了
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.
该函数不会搜索子窗口。按键控件属于格式化窗口的子窗口,所以FindWindow()函数不起作用。

用 EnumChildWindows 找到了按钮,如果想给按钮发送鼠标左键单击消息,是应该发给按钮还是按钮的父窗口?[/quote]
应该发给按钮
孤必有邻 2019-03-21
  • 打赏
  • 举报
回复
向按钮发送BN_CLICKED命令
::SendMessage(hWndOK,WM_COMMAND,BN_CLICKED,0);
谁学逆向工程 2019-03-21
  • 打赏
  • 举报
回复
引用 4 楼 棉猴 的回复:
MSDN上说了 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. 该函数不会搜索子窗口。按键控件属于格式化窗口的子窗口,所以FindWindow()函数不起作用。
用 EnumChildWindows 找到了按钮,如果想给按钮发送鼠标左键单击消息,是应该发给按钮还是按钮的父窗口?
轻箬笠 2019-03-21
  • 打赏
  • 举报
回复
另外,发送点击消息好像是发给窗体的。用法如下:
::SendMessage(hWnd, WM_COMMAND, MAKEPARAM(BTN_ID, BN_CLICKED), 0);
轻箬笠 2019-03-21
  • 打赏
  • 举报
回复
先用FindWindow获取主窗口的句柄。然后调用FindWindowEx获取按钮的句柄。
这里有个例子可以看下。
const int BM_CLICK = 0xF5;
IntPtr maindHwnd = FindWindow(null, "QQ用户登录"); //获得QQ登陆框的句柄
if (maindHwnd != IntPtr.Zero)
{
IntPtr childHwnd = FindWindowEx(maindHwnd, IntPtr.Zero, null, "登录"); //获得按钮的句柄
if (childHwnd != IntPtr.Zero)
{
SendMessage(childHwnd, BM_CLICK, 0, 0); //发送点击按钮的消息
}
else
{
MessageBox.Show("没有找到子窗口");
}
}
else
{
MessageBox.Show("没有找到窗口");
}

原文地址https://www.cnblogs.com/easypass/p/4067484.html
棉猴 2019-03-20
  • 打赏
  • 举报
回复
MSDN上说了
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.
该函数不会搜索子窗口。按键控件属于格式化窗口的子窗口,所以FindWindow()函数不起作用。
谁学逆向工程 2019-03-20
  • 打赏
  • 举报
回复
引用 2 楼 jiht594 的回复:
这函数看起来不查子窗口 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.
想找到开始按钮,然后发送鼠标左键单击消息,用什么思路解决?
jiht594 2019-03-19
  • 打赏
  • 举报
回复
这函数看起来不查子窗口

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.
jiht594 2019-03-19
  • 打赏
  • 举报
回复
BUTTON改成Button试试

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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