how to get window title and visible window text?

Waiting_Ai 2005-08-04 11:33:03
比如安装超星阅览器的安装窗口我如何获取
window title:安装 超星阅览器 3.8,

visible window text:
欢迎使用 超星阅览器 3.8 安装向导

本程序将安装 超星阅览器 3.8 到您的计算机中。

强烈建议您在继续安装之前关闭其他所有正在运行的程序,以避免安装过程中可能产生的相互冲突。

单击“下一步”继续,“取消”退出安装。
下一步(N) >
取消
?
TKS!
...全文
76 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Waiting_Ai 2005-08-17
  • 打赏
  • 举报
回复
我的问题已经解决,现在share出来,XDJM多多指教!

#include <afx.h>
#include <Afxwin.h>
#include <iostream.h>
const STRINGLEN=256;
int i = 0;
CString text;
CString Needtitle ="安装 - CyberArticle";
CString Needtext = "欢迎使用 CyberArticle 安装向导";
int CALLBACK MyEnumChildWindowsProc(HWND hwnd, LPARAM lParam)
{
//CMyView* pView = (CMyView*)lParam;
//pView->AddChildWindowToList(hwnd);
CString s;
GetClassName(hwnd, s.GetBuffer(STRINGLEN),STRINGLEN);
s.ReleaseBuffer();
cout<<"class:"<<s<<endl;
CWnd* pWnd = CWnd::FromHandle(hwnd);
pWnd->GetWindowText(s);
cout<<"text:"<<s<<endl;
text.Format(_T("%s%s"),text,s);
return 1;
}
int CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
{
CWnd* pWnd = CWnd::FromHandle(hwnd);
if (hwnd!=pWnd->GetParentFrame()->GetSafeHwnd())
{
DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
if ((dwStyle & WS_OVERLAPPEDWINDOW) && (dwStyle & WS_VISIBLE))
{
i++;
cout<<"//////////////////////"<<i<<"//////////////////////"<<endl;
// class name
CString s;
//::GetClassName(hwnd, s.GetBuffer(STRINGLEN), STRINGLEN);
// window text -- use GetWindowText
pWnd->GetWindowText(s);
cout<<"Windows title:";
cout<<s<<endl;
if(s.Compare(Needtitle)==0)
{
// window's children
EnumChildWindows(hwnd, MyEnumChildWindowsProc, NULL);
cout<<"text:"<<text<<endl;
SetForegroundWindow(hwnd);
}
s.ReleaseBuffer();
}
}
text.Empty();
text.GetBuffer(1000);
return 1;
}
int main(int argc, char* argv[])
{
text.GetBuffer(1000);
EnumWindows(MyEnumWindowsProc,NULL);
return 0;
}
healer_kx 2005-08-04
  • 打赏
  • 举报
回复
GetWindowText啊。相关的API可能用到FindWindow什么的。

下一步什么的用GetDlgItem。

Hook估计也需要用到。
Waiting_Ai 2005-08-04
  • 打赏
  • 举报
回复
TKS healer_kx(天降甘草),GetWindowText只能得到窗口的标题。窗口上的其它信息得不到。
Hook不知道怎么用。

64,682

社区成员

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

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