var ShellWindow: IShellWindows; nCount: integer; spDisp: IDispatch; i, j: integer; vi: OleVariant; IE1: IWebBrowser2; begin ShellWindow := CoShellWindows.Create; nCount := ShellWindow.Count; for i := 0 to nCount - 1 do begin vi := i; Sleep(10); try spDisp := ShellWindow.Item(vi); except exit end; if (spDisp <> nil) then begin //························· try spDisp.QueryInterface(iWebBrowser2, IE1);
if (IE1 <> nil) then begin { 这里就是获得了ie的接口,你就可以做这个ie做所有的操作了 }
HWND hwnd1 = ::FindWindowEx(hwnd, 0, "WorkerW", NULL);
HWND hwnd2 = ::FindWindowEx(hwnd1,0, "ReBarWindow32", NULL);
HWND hwnd3 = ::FindWindowEx(hwnd2,0, "ComboBoxEx32", NULL);
HWND hwnd4 = ::FindWindowEx(hwnd3,0, "ComboBox", NULL);
HWND hwnd5 = ::FindWindowEx(hwnd4,0, "Edit", NULL);
char Buffer[256];
::SendMessage(hwnd5, WM_GETTEXT, 256, LPARAM(Buffer));
MessageBox(Buffer);
HWND hwnd1 = ::FindWindowEx(hwnd, 0, "WorkerW", NULL);
HWND hwnd2 = ::FindWindowEx(hwnd1,0, "ReBarWindow32", NULL);
HWND hwnd3 = ::FindWindowEx(hwnd2,0, "ComboBoxEx32", NULL);
HWND hwnd4 = ::FindWindowEx(hwnd3,0, "ComboBox", NULL);
HWND hwnd5 = ::FindWindowEx(hwnd4,0, "Edit", NULL);
char Buffer[256];
::SendMessage(hwnd5, WM_GETTEXT, 256, LPARAM(Buffer));
MessageBox(Buffer);————————————————————————————————
处理 WM_KEYDOWN 消息,判断是否按下回车键
一篇好文章,对你应该很有帮助
过程有些烦,但不是很难,你可以试一下.EnumChildWindows这个可以枚举当前窗口控件,我们可以继续在此讨论该问题.
Hook只是在hook上的进程的内存中做 一个诱导或者陷入 自己的一个函数作用,不只用来获取表面上的东西的,比如你做一个动作 会触发一个事件,我想让这个事件接口地址jmp到另外的内存地址上,这样 才是hook的作用
不知道对不对如果要获得ie上的地址,我想到的有两个方法,
第一个,就是 no111(哈里路亚) 说的
SendMessage(hwnd5, WM_GETTEXT, 256, LPARAM(Buffer));
但是不一定准确,因为如果ie上不只一个edit输入框,就有可能得不到你所需要的内容第二个,继承ie接口的方法,可以遍历所有windows打开的接口,进行匹配是否为ie接口,如果是继承过来,这样就可以对这个ie内核的浏览器获取所有的设置或者 做所有的东西了
具体代码我只是写过delphi的,我觉得应该c++好转换过去,我贴出来哈function TGETIEThread.GetContent(Handle: HWND): string;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i, j: integer;
vi: OleVariant;
IE1: IWebBrowser2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
Sleep(10);
try
spDisp := ShellWindow.Item(vi); except
exit
end;
if (spDisp <> nil) then
begin //·························
try
spDisp.QueryInterface(iWebBrowser2, IE1);
if (IE1 <> nil) then
begin
{
这里就是获得了ie的接口,你就可以做这个ie做所有的操作了
}
end;
end;
end;end;
// TestIe.cpp : 定义控制台应用程序的入口点。
//#include <stdio.h>
#include "stdafx.h"
#include "TestIe.h"
#include "mshtml.h"
#include <comutil.h>#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一的应用程序对象CWinApp theApp;using namespace std;int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0; // 初始化 MFC 并在失败时显示错误
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("错误: MFC 初始化失败\n"));
nRetCode = 1;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
}
::CoInitialize(NULL);
IShellWindows* m_spSHWinds;
::CoCreateInstance( CLSID_ShellWindows,NULL,CLSCTX_INPROC_SERVER,IID_IShellWindows,(LPVOID*)&m_spSHWinds);
long nCount;
CStringA str; m_spSHWinds->get_Count(&nCount);
BSTR Url ;
for (long i = 0; i < nCount; i++)
{
VARIANT va;
va.vt = VT_I4;
va.lVal = i;
IDispatch* spDisp;
m_spSHWinds->Item(va,&spDisp);
IWebBrowser2* spBrowser;
spDisp->QueryInterface(IID_IWebBrowser2,(void**)&spBrowser);
if (spBrowser != NULL)
{
IHTMLDocument2* spDoc;
IDispatch* IDispDoc;
spBrowser->get_Document(&IDispDoc);
IDispDoc->QueryInterface(IID_IHTMLDocument2,(void**)&spDoc);
if (spDoc != NULL)
{
spDoc->get_URL(&Url);
str = Url;
cout <<( str) <<endl ;
}
} }
::CoUninitialize();
return nRetCode;
}
用sniffer匹配GET/POST数据包更容易一些.