Ver Mensaje Individual
  #6  
Antiguo 08-04-2006
lpkwebagent007 lpkwebagent007 is offline
Registrado
 
Registrado: abr 2006
Posts: 7
Reputación: 0
lpkwebagent007 Va por buen camino
todo resuelto..gracias!!!!

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.dfm}
Function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value: string): Boolean;
var
  i, j: Integer;
  FormItem: Variant;
begin
  Result := False;
  //no form on document
  if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then
  begin
    Exit;
  end;
  //count forms on document
  for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do
  begin
    FormItem := WebBrowser.OleObject.Document.forms.Item(I);
    for j := 0 to FormItem.Length - 1 do
    begin
      try
        //when the fieldname is found, try to fill out
        if FormItem.Item(j).Name = FieldName then
        begin
          FormItem.Item(j).Value := Value;
          Result := True;
        end;
      except
        Exit; 
      end;
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
Begin
if FillForm(WebBrowser1, 'username', 'yoo soy user') = False then
    ShowMessage('Error. El campo "username" no se encuentra');
if FillForm(WebBrowser1, 'password', 'y yo soy pasword') = False then
    ShowMessage('Error. El campo "password" no se encuentra');
End;

procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.yosoytuloginparticular');
end;

end.

Última edición por lpkwebagent007 fecha: 08-04-2006 a las 04:33:12.
Responder Con Cita