I know that it is possible to capture the FIREFOX URL using DDEClient, but has anyone used it to get the source code for the page open?
Follow the code to capture the title:
procedure TForm1.GetCurrentURL(var sURL: String; var sTitle: String; var sSource: String);
var
DDEClient : TDDEClientConv;
s : String;
begin
s := '';
try
DDEClient := TDDEClientConv.Create(self);
with DDEClient do
begin
if SetLink('IExplore','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle');
sSource := 'Source: IE';
end
else
if SetLink('Netscape','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle');
sSource := 'Source: IE';
end
else
if SetLink('Mosaic','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle');
sSource := 'Source: Mosaic';
end
else
if SetLink('Chrome','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle');
sSource := 'Source: Netscape 6';
end
else
if SetLink('Mozilla','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle');
sSource := 'Source: Mozilla';
end
else
if SetLink('Firefox','WWW_GetWindowInfo') then
begin
s := RequestData('0xFFFFFFFF, sURL, sTitle, sSource');
sSource := 'Source: FireFox';
end;
end;
if s <> '' then
begin
Delete(s, 1, 1);
sURL := 'URL: ' +Copy(s, 1, pos('","',s)-1);
Delete(s, 1, Pos('","', s)+2);
sTitle := 'Title: ' +Copy(s, 1, Pos('"', s) - 1);
end;
exit;
except
MessageDlg('URL attempt failed!',mtError,[mbOK],0);
end;
end;
To Use:
procedure TForm1.Button1Click(Sender: TObject);
var
sURL, sTitle, sSource: String;
begin
GetCurrentURL(sURL, sTitle, sSource);
Memo1.Lines.Add(sURL);
Memo1.Lines.Add(sTitle);
Memo1.Lines.Add(sSource);
end;