用COM接口实现。。。
我这你有段去表单内容的 你拿去参考一下吧
function TForm1.GetDocInterface(hwnd:THandle):IHtmlDocument2;
var
hInst: THandle;
hr:HResult;
lRes:Cardinal;
MSG: Integer;
spDisp:IDispatch;
spDoc:IHTMLDocument;
pDoc2:IHTMLDocument2;
spWin:IHTMLWindow2;
ObjectFromLresult: TObjectFromLresult;
begin
hInst := LoadLibrary('Oleacc.dll');
if hInst=0 then exit;
@ObjectFromLresult := GetProcAddress(hInst, 'ObjectFromLresult');
if @ObjectFromLresult <> nil then begin
try
MSG := RegisterWindowMessage('WM_HTML_GETOBJECT');
SendMessageTimeOut(Hwnd, MSG, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes);
hr:= ObjectFromLresult(lRes, IHTMLDocument2, 0, spDoc);
if SUCCEEDED(hr) then
begin
spDisp:=spDoc.Script;
spDisp.QueryInterface(IHTMLWindow2,spWin);
//spWin:=IHTMLWindow2(spDisp);
result:=spWin.document;
end;
finally
FreeLibrary(hInst);
end;
end;
end;
procedure TForm1.GetPassword(pdoc2:IHTMLDocument2;pt:TPoint);
var
ltype:string;
pwd:string;
pElement:IHTMLElement;
pPwdElement:IHTMLInputTextElement;
hr:HRESULT;
begin
if (pDoc2=Nil) then exit;
pElement:=pDoc2.elementFromPoint(pt.X,pt.Y);
hr:=pElement.QueryInterface(IID_IHTMLInputTextElement,pPwdElement);
if(SUCCEEDED(hr)) then
begin
if (pPwdElement.type_='password') and (pPwdElement.value<>'') then
begin
Edit1.text:=pPwdElement.value;
end else
if (pPwdElement.type_='text') and (pPwdElement.value<>'') then
Edit2.Text:=pPwdElement.value;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
pt:TPoint;
handle:Thandle;
buffer
Char;
strbuffer:string;
begin
//GetCursorPos(pt);
pt:=GetPoint;
handle:=WindowFromPoint(pt);
if handle<>0 then
begin
GetClassName(handle,buffer,100);
strbuffer:=strpas(buffer);
if strbuffer='Internet Explorer_Server' then
begin
// pt:=ScreenToClient(pt);
Windows.ScreenToClient(handle,pt);
Edit3.Text:=IntToStr(pt.x)+' '+IntToStr(pt.Y);
GetPassword(GetDocInterface(handle),pt);
end;
end;
end;