怎样获取一个网页中的某个录入框,并填写内容? ( 积分: 50 )

  • 主题发起人 主题发起人 国色天香
  • 开始时间 开始时间

国色天香

Unregistered / Unconfirmed
GUEST, unregistred user!
比如大富翁登录时,富翁名称那个录入框,怎样用自动填充富翁姓名?
 
使用WebXXX接口
然后根据名称找到录框
再调用想应的方法赋值就 行了
 
学习中,楼上的能否给个代码
 
怎样才能知道名称?
 
我这你有段去表单的 你拿去参考一下吧
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:PChar;
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;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部