Einzelnen Beitrag anzeigen

Mirco

Registriert seit: 7. Mai 2006
71 Beiträge
 
#3

Re: Memo in anderem Programm auslesen

  Alt 19. Jun 2006, 15:50
Hallo
Ich hab mal beim Internet Explorer folgendes gemacht um mich automatisch bei einem HTAcess Fenster einzuloggen:
Der Quelltext ist nicht von mir.
Delphi-Quellcode:
function TForm1.feld: boolean;
var
  ShellWindow: IShellWindows;
  WB: IWebbrowser2;
  spDisp: IDispatch;
  IDoc1: IHTMLDocument2;
  Document: Variant;
  k, m: Integer;
  ovElements: OleVariant;
  i: Integer;
begin
  result := false; //assume no go

  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 try

        WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
      except
      end;
      if iDoc1 <> nil then
      begin
        WB := ShellWindow.Item(k) as IWebbrowser2;
        begin
          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 := 0 to ovElements.Length - 1 do
            begin
              // when input fieldname is found, try to fill out
              try
                if (CompareText(ovElements.item(i).tagName, 'INPUT') = 0) and
                  (CompareText(ovElements.item(i).type, 'text') = 0) then
                begin
                  ovElements.item(i).Value := 'username';
                end;
              except
              end;
                try
                if (CompareText(ovElements.item(i).tagName, 'INPUT') = 0) and
                  (CompareText(ovElements.item(i).type, 'SUBMIT') = 0) and
                  (ovElements.item(i).Value = 'weiter') then // Suchen für German
                begin
                  ovElements.item(i).Click;
                  result := true; // we're a go!

                end;
              except
              end;
            end;
          end;
        end;
      end;
    end;
  end;
end;
Die Anordnung meines Fensters in der anderen Anwendung sieht so aus:
Delphi-Quellcode:
786638: TDataForm "Data"
  786640: TPanel "Panel1"
    721098: TPanel
      983250: TMemo "TExt"
Ich bekomm den Quelltext oben nicht angepasst.
Grüsse
Mirco
Mirco Hallenga
  Mit Zitat antworten Zitat