VC获取其他软件控件的内容
2014-10-31 14:54
357 查看
// GetWindowData.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "GetWindowData.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // 唯一的应用程序对象 //CString strTitle = "RGBLPR车牌识别系统 V4.0"; //CString strClass = "Button"; CString strTitle = "过期域名抢注软件1.2——索雅软件(SoYaSoft.com)"; CString strClass = "ListView20WndClass"; CWinApp theApp; using namespace std; void MyFindListViewWindow(CString strTitle, CString strClass); BOOL CALLBACK EnumChildProc( HWND hwnd, // handle to child window LPARAM lParam // application-defined value ) { Sleep(500); char WindowTitle[100] = { NULL }; GetWindowText(hwnd, WindowTitle, 100); int nCount = ::SendMessage(hwnd, LB_GETCOUNT, 0, 0); if (nCount <= 0) { cerr << "获取ListBox总行数失败!" << endl; } else { char szBuf[255]; int nt = 0; for (int i = 0; i < nCount; i++) { nt = (int)::SendMessage(hwnd, LB_GETTEXT, i, (LPARAM)szBuf); if (nt == LB_ERR) { break; } cerr << "shuju:" << szBuf << endl; } } //EnumChildWindows(hwnd, (WNDENUMPROC)EnumChildProc, NULL); if (strlen(WindowTitle) == 0) { cerr << "句柄: " << hwnd << endl; cerr << "标题: " << _T("Emty!") << endl; char str[100]; memset(str, 0, sizeof(str)); //GetWindowText(hwnd, str, sizeof(str)); //获取控件的TEXT //SendMessage(hwnd, WM_GETTEXT, 100, (LPARAM)str); GetClassName(hwnd, str, 100); cerr << "info: " << str << endl; cerr << _T("<<<<<<<<<<<<<<<<<<<<") << endl; return true; } else { cerr << "句柄: " << hwnd << endl; cerr << "标题 " << _T(WindowTitle) << endl; if (0 == strcmp("打开多幅图像...", WindowTitle)) { PostMessage(hwnd, WM_LBUTTONDOWN, NULL, NULL); PostMessage(hwnd, WM_LBUTTONUP, NULL, NULL); MyFindListViewWindow("打开", "Edit"); } char str[100]; memset(str, 0, sizeof(str)); //GetWindowText(hwnd, str, sizeof(str)); //获取控件的TEXT //SendMessage(hwnd, WM_GETTEXT, 100, (LPARAM)str); GetClassName(hwnd, str, 100); cerr << "info: " << str << endl; cerr << _T("********************") << endl; return true; } EnumChildWindows(hwnd, (WNDENUMPROC)EnumChildProc, NULL); return true; } void MyFindListViewWindow(CString strTitle, CString strClass) { HWND hParentWnd = NULL; HWND hChild = NULL; hParentWnd = ::FindWindow(NULL, strTitle); if (hParentWnd == NULL) { ::AfxMessageBox("查找窗口失败!"); return; } //再得到LISTBOX句柄 hChild = FindWindowEx(hParentWnd, NULL, strClass, NULL); if (hChild == NULL) { ::AfxMessageBox("查找ListBox失败!"); return; } //发消息获取数据显示到我的LISTBOX int nCount = ::SendMessage(hChild, LB_GETCOUNT, 0, 0); if (nCount <= 0) { ::AfxMessageBox("获取ListBox总行数失败!"); //return; } char szBuf[100]; ListView_GetItemText(hChild, 0, 0, szBuf, 100); cerr << szBuf << endl; //先清空自己的数据 return; int nt = 0; for (int i = 0; i < 2; i++) { nt = (int)::SendMessage(hChild, LB_GETTEXT, i, (LPARAM)szBuf); if (nt == LB_ERR) { break; } cerr << "shuju:" << szBuf << endl; } } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL) { // 初始化 MFC 并在失败时显示错误 if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0)) { // TODO: 更改错误代码以符合您的需要 _tprintf(_T("错误: MFC 初始化失败\n")); nRetCode = 1; } else { // TODO: 在此处为应用程序的行为编写代码。 MyFindListViewWindow(strTitle, strClass); return 0; HWND myhwnd; myhwnd = ::FindWindow(NULL, "RGBLPR车牌识别系统 V4.0"); //myhwnd = ::FindWindow(NULL, "打开"); if (NULL == myhwnd) { ::AfxMessageBox("meiyou"); } else { //MyFindListViewWindow(); ::AfxMessageBox("you"); EnumChildWindows(myhwnd, (WNDENUMPROC)EnumChildProc, NULL); ::AfxMessageBox("end"); } } } else { // TODO: 更改错误代码以符合您的需要 _tprintf(_T("错误: GetModuleHandle 失败\n")); nRetCode = 1; } return nRetCode; }
相关文章推荐
- 【VC版】如何获取其他进程中ListView控件中的内容
- 【VC版】如何获取其他进程中ListView控件中的内容
- Windows获取其他进程中Edit控件的内容
- VC获取其他进程ListCtrl内容
- VC获取其他进程ListCtrl内容
- 读取其他软件listview控件的内容
- C#如何获取其他程序ListView控件中的内容
- C#如何获取其他程序ListView控件中的内容 含源码
- 使用VC编写ocx控件,通过读注册表项获取客户端软件版本号
- VC获取其他进程ListCtrl内容
- VC获取其他进程ListCtrl内容
- VC获取其他进程ListCtrl内容
- 在一个组件中调用其他组件的内容||android中怎样在activity中获取fragment中的控件
- 一个很不错的清空页面所有文本框内容的函数(也可随意改成页面其他控件类型)
- 获取其他进程中“Internet Explorer_TridentCmboBx”的内容
- 用.net实现远程获取其他网站页面内容
- 如何获取模版列中的控件的内容?
- 获取其他窗口中控件的方法
- 《如何更改其他程序ListView控件中某个Item的内容》 -- 天津 赵春生
- 获取其他进程中ListBox和ComboBox的内容