PDA

Ver la Versión Completa : Obtener URL en mozilla/firefox


jorodgar
24-06-2005, 21:05:47
¿ Existe forma de saber que páginas esta visitando un usuario que tiene mozilla/firefox?
Con IE si lo encontre pero con otros navegadores no he tenido suerte.
¿ Alguna idea ? Gracias. :)

jorodgar
25-06-2005, 22:52:55
De momento solo he obtenido el titulo haciendo lo siguiente.
Me he guiado con el programa WinSPy 1.0 para obtener las classes.
Como obtengo la URL??? :(


unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
lbIEURL: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

function GetUrlFromFirefox (Handle: THandle; List: TStringList): boolean; stdcall;

implementation

{$R *.dfm}

function GetUrlFromFirefox (Handle: THandle; List: TStringList): boolean; stdcall;
var
hWndFX, hWndFXChild : HWND;
Buffer : array[0..255] of Char;
begin
SendMessage(Handle, WM_GETTEXT, 255, integer(@Buffer[0]));

hWndFX := FindWindow('MozillaWindowClass', Buffer);
if hWndFX > 0 then
begin
SendMessage(hWndFXChild, WM_GETTEXT, 255, integer(@Buffer));
if buffer<>'' then
List.AddObject(Buffer,TObject(hWndFX));
end;
Result :=True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
lbIEURL.Clear;
EnumWindows(@GetUrlFromFirefox, LParam(lbIEURL.Items));
end;

end.

jorodgar
26-06-2005, 22:44:31
A continuación el código fuente:


unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetCurrentURL (var URL, Title : string);
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.GetCurrentURL (var URL, Title : string);
var
DDEClient : TDDEClientConv;
s : string;
begin
s := '';
try
DDEClient := TDDEClientConv.Create(self);
with DDEClient do
begin
if SetLink('IExplore','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle')
else
if SetLink('Netscape','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle')
else
if SetLink('Mosaic','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle')
else
if SetLink('Netscp6','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle')
else
if SetLink('Mozilla','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle')
else
if SetLink('Firefox','WWW_GetWindowInfo') then
s := RequestData('0xFFFFFFFF,sURL,sTitle');
end;
if s <> '' then
begin
delete(s,1,1);
URL := copy(s,1,pos('","',s)-1);
delete(s,1,pos('","',s)+2);
Title := copy(s,1,pos('"',s) - 1);
end;
exit;
except
MessageDlg('URL attempt failed!',mtError,[mbOK],0);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
URL : string;
Title : string;
begin
GetCurrentURL (URL, Title);
Edit1.Text := URL;
Edit2.Text := Title;
end;

end.