AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ExecuteScript?!

Ein Thema von Evian · begonnen am 28. Apr 2004 · letzter Beitrag vom 28. Apr 2004
Antwort Antwort
Benutzerbild von Evian
Evian

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

ExecuteScript?!

  Alt 28. Apr 2004, 10:16
Ich habe bei Swissdelphicenter einen Code gefunden um JS Formulare
im Internet automatisch ausfüllen zu können. -> URL

Das Problem ist nur, dass meine IDE den Befehl ExecuteScript nicht kennt,
obwohl ich alle Units eingebunden habe. Hat Jemand eine Ahnung, woran das
liegen könnte?! Ich nutze zur Zeit zu Testzwecken Delphi 7 [Pro]

gruss


Evian
-> www.Phillsoft.de

Ich bin nun Mathematiker, aber meine Freundin bleibt trotzdem unberechenbar!
  Mit Zitat antworten Zitat
citybreaker
(Gast)

n/a Beiträge
 
#2

Re: ExecuteScript?!

  Alt 28. Apr 2004, 11:06
Öh, hast du shellapi bei uses eingebunden?
  Mit Zitat antworten Zitat
Benutzerbild von Evian
Evian

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

Re: ExecuteScript?!

  Alt 28. Apr 2004, 11: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
citybreaker
(Gast)

n/a Beiträge
 
#4

Re: ExecuteScript?!

  Alt 28. Apr 2004, 11:23
Ähm bei dem oberen link steht noch folgene funktion bei names "excutescript".
Tu die mal mit in Unit1 packen.

Delphi-Quellcode:
function ExecuteScript(doc: IHTMLDocument2; script: string; language: string): Boolean;
var
  win: IHTMLWindow2;
  Olelanguage: Olevariant;
begin
  if doc <> nil then
  begin
    try
      win := doc.parentWindow;
      if win <> nil then
      begin
        try
          Olelanguage := language;
          win.ExecScript(script, Olelanguage);
        finally
          win := nil;
        end;
      end;
    finally
      doc := nil;
    end;
  end;
end;
  Mit Zitat antworten Zitat
Benutzerbild von Evian
Evian

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

Re: ExecuteScript?!

  Alt 28. Apr 2004, 11:25
oh man *auf den kopf hau* ... bin ich ein Obertrottel!!!

*g* -> öhm, können wir so tun, als hät ich nie gefragt?!
-> www.Phillsoft.de

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


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz