Thema: Delphi IE: Felder ausfüllen

Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#2
  Alt 17. Mai 2003, 23:28
Zitat:
Mein Programm soll die laufenden IE-Instanzen auflisten
Kannst du über IShellWindows. Siehe .hier

Hier noch ein Codeschnippsel, welcher alle laufenden IE Instanzen
auflistet und dann über das IWebbrowser2 Interface die Items
eines Dokumentes auflistet, usw.

Code:
var
  ShellWindow: IShellWindows;
  WB: IWebbrowser2;
  spDisp: IDispatch;
  IDoc1: IHTMLDocument2;
  Document: Variant;
  i, k, m: Integer;
  ovElements: OleVariant;
begin
  ShellWindow := CoShellWindows.Create;
  // get the running instance of Internet Explorer
  for k := 0 to ShellWindow.Count do
  begin
    spDisp := ShellWindow.Item(k);
    if spDisp = nil then Continue;
    // QueryInterface determines if an interface can be used with an object
    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;
        Document := WB.Document;
          for m := 0 to Document.forms.Length - 1 do
          begin
            ovElements := Document.forms.Item(m).elements;

            // iterate through elements
            for i := ovElements.Length - 1 downto 0 do
            begin
              try
              // if input fields found, try to fill them out
                if (ovElements.item(i).tagName = ...
                  (ovElements.item(i).type = ...
                  begin
                 
                    // ...
                  end;
              except
                // failed...
              end;
            end; { for i...}
          end; { for m }
      end; { idoc <> nil }
    end; { wb <> nil }
    // ...
  end; { for k }
end;
Thomas
  Mit Zitat antworten Zitat