Kód: Vybrat vše
procedure TForm1.Button2Click(Sender: TObject);
var
ShellWindow: IShellWindows;
WB: IWebbrowser2;
spDisp: IDispatch;
IDoc1: IHTMLDocument2;
Document: Variant;
k, m: Integer;
ovElements: OleVariant;
i: Integer;
begin
ShellWindow := CoShellWindows.Create;
for k := 0 to ShellWindow.Count do
begin
spDisp := ShellWindow.Item(k);
if spDisp = nil then Continue;
spDisp.QueryInterface(iWebBrowser2, WB);
if WB <> nil then
begin
WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
if iDoc1 <> nil then
begin
WB := ShellWindow.Item(k) as IWebbrowser2;
begin
Document := WB.Document;
for m := 0 to Document.forms.Length - 1 do
begin
ovElements := Document.forms.Item(m).elements;
for i := 0 to ovElements.Length - 1 do
begin
try
if (CompareText(ovElements.item(i).tagName, 'input') = 0) and (CompareText(ovElements.item(i).type, 'text') = 0) then
ovElements.item(i).Value := 'Delphi';
except
end;
try
if (CompareText(ovElements.item(i).tagName, 'input') = 0) and (CompareText(ovElements.item(i).type, 'submit') = 0) and (ovElements.item(i).Value = 'Vyhledat Googlem') then
ovElements.item(i).Click;
except
end;
end;
end;
end;
end;
end;
end;
end;
kdyz mam spustene jine okno exploreru jde to v pohode, sice musim nastavit rucne adresu ale jde to. Kdyz ale dam vlastnost webbrowseru na tom formulari register as browser na true, vyhodi mi to chybu acces violation at adress atd. Označený je pak tento řádek :
Kód: Vybrat vše
WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
Nevíte někdo, kde by mohla být chyba? předem díky za odpovědi....