Einzelnen Beitrag anzeigen

seddto1977

Registriert seit: 15. Apr 2004
69 Beiträge
 
#3

Re: Welchen Class-Namen haben Edit-Boxen in Webbrowsern?

  Alt 12. Mai 2004, 09:31
So, hab mal im Forum gesucht und einen Codeschnipsel den ich gefunden hab, etwas modifiziert, leider gehts nicht

Code:
function GetString: Boolean;
type
  TIEFields = record
    tagName : String;
    fType : String;
  end;
const
  MaxIEFields = 2;
  IEFields: array[1..MaxIEFields] of TIEFields = (
    (tagName : 'INPUT'; fType : 'text'),
    (tagName : 'INPUT'; fType : 'password'));

var
  Mail: String;
  ShellWindow: IShellWindows;
  WB: IWebbrowser2;
  spDisp: IDispatch;
  IDoc1: IHTMLDocument2;
  Document: Variant;
  k, m: Integer;
  ovElements: OleVariant;
  i: Integer;
  IEFieldsCounter: Integer;
  IEFormName : array[1..MaxIEFields] Of String;
begin
  result := false;
  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);
    IEFieldsCounter := 0;
    if WB <> nil then
    begin
      WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
      if iDoc1 <> nil then
      begin
        WB := ShellWindow.Item(k) as IWebbrowser2;
        Document := WB.Document;



          // count forms on document and iterate through its forms
          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 Pos('@', ovElements.item(i).Value) > 0 then
                      begin
                        Mail := '<' +  ovElements.item(i).Value + '>';
                        String_Cut (Mail);
                        inc(IEFieldsCounter);

                      end;


              except
                // failed...
              end;
            end; { for i...}
          end; { for m }
      end; { idoc <> nil }
    end; { wb <> nil }

  end; { for k }
end;
Ich möchte damit einfach für meinen Mail-Clienten Email-Adressen aus Webformularen auslesen und dem user anbieten sie ins Adressbuch hinzuzufügen. Die function wird zwar komplett durchlaufen, allerdings findet sie nie etwas...Weiss jemand was ich falsch gemacht habe?
  Mit Zitat antworten Zitat