Thema: Delphi ExecuteScript?!

Einzelnen Beitrag anzeigen

Benutzerbild von Evian
Evian

Registriert seit: 10. Apr 2003
Ort: Berlin
485 Beiträge
 
Delphi 6 Professional
 
#3

Re: ExecuteScript?!

  Alt 28. Apr 2004, 12:18
Mein Code ist follgender:

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MSHTML_TLB, SHDocVw_TLB, ShDocVW, ShellAPI, StdCtrls, OleCtrls;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Button1: TButton;
  procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}
procedure FillInGMXForms(WB: ShDocVW_TLB.IWebbrowser2; IDoc1: IHTMLDocument2;
  Document: Variant; AKennung, APasswort: string);
const
  IEFields: array[1..4] of string = ('INPUT', 'text', 'INPUT', 'password');
var
  IEFieldsCounter: Integer;
  i: Integer;
  m: Integer;
  ovElements: OleVariant;
begin
  if Pos('GMX - Homepage', Document.Title) <> 0 then

    while WB.ReadyState <> READYSTATE_COMPLETE do
      Application.ProcessMessages;

  // count forms on document and iterate through its forms
  IEFieldsCounter := 0;
  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 = IEFields[1]) and
          (ovElements.item(i).type = IEFields[2]) then
        begin
          ovElements.item(i).Value := AKennung;
          Inc(IEFieldsCounter);
        end;

        if (ovElements.item(i).tagName = IEFields[3]) and
          (ovElements.item(i).type = IEFields[4]) then
        begin
          ovElements.item(i).Value := APasswort;
          Inc(IEFieldsCounter);
        end;
      except
        // failed...
      end;
    end; { for i...}
  end; { for m }
  // if the fields are filled in, submit.
  if IEFieldsCounter = 3 then ExecuteScript(iDoc1, 'document.login.submit()',
      'JavaScript');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  IDoc1: IHTMLDocument2;
  Web: ShDocVW_TLB.IWebBrowser2;
begin
  Webbrowser1.Navigate('http://www.gmx.ch');
  while Webbrowser1.ReadyState <> READYSTATE_COMPLETE do
    Application.ProcessMessages;
  Webbrowser1.Document.QueryInterface(IHTMLDocument2, iDoc1);
  Web := WebBrowser1.ControlInterface;
  FillInGMXForms(Web, iDoc1, Webbrowser1.Document, 'user@gmx.net', 'pswd');
end;
end.
und die Fehlermeldung:
[Fehler] Unit1.pas(72): Undefinierter Bezeichner: 'ExecuteScript'

in welcher Unit genau, soll denn "ExecuteScript" drin sein?!
Und könntest Du(oder jemand anderes) die unit mal hochladen?!


gruss

Evian
-> www.Phillsoft.de

Ich bin nun Mathematiker, aber meine Freundin bleibt trotzdem unberechenbar!
  Mit Zitat antworten Zitat