Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2004, 11:18 AM
so3 so3 is offline
Member
 
Join Date: Nov 2004
Posts: 78
Default Read url from Firefox

Is there a way to get the url from a firefox window. i know that Firefox/Netscape is designing the toolbar and that why i can fing\d the correct class.
Reply With Quote
  #2  
Old 11-19-2004, 11:48 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: Read url from Firefox

Try this code:
Code:
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;
MrBaseball34
Hook'Em Horns!
Reply With Quote
  #3  
Old 11-19-2004, 12:58 PM
so3 so3 is offline
Member
 
Join Date: Nov 2004
Posts: 78
Default RE: Read url from Firefox

Hi,
It seems taht you're my hero. Thank you the code works. Is there a way to find the url for all the instances.

I didn't think that is so easy to get the urls from Firefox. i bound to your wisdom

so3
Reply With Quote
  #4  
Old 11-19-2004, 01:12 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: Read url from Firefox

From all the IE windows, you have to iterate through them
using ShellWindows and then query the Document for it's location property.

For Firefox, I don't even know and no one is telling,
either. I've asked till I'm blue in the face on all the
Firefox forums I know of and can't get an answer AT ALL.


MrBaseball34
Hook'Em Horns!
Reply With Quote
  #5  
Old 11-19-2004, 02:23 PM
so3 so3 is offline
Member
 
Join Date: Nov 2004
Posts: 78
Default RE: Read url from Firefox

I have the solution for IE, i don't need it.
As for firefox,netscape mozilla i've tried myself too and without solution.

Did you tried to read the urls from a Myie2 browser?
Myie2 is based on Internet Explorer but when i use your code for Mozilla it's reading the url from myie2.
If i have myie2 and mozilla browsers opened at the same time i read the url only from myie2 and not mozilla (using as mozilla in requestdata).
So can you tell if you know how to verify that is indeed mozilla browser and not myie2.

I've done a bookmark manager that grabs urls from opera,netscape,mozilla,irider,myie2,firefox,etc and the code that you gave me helped me a lot. I wasn't especting to receive help so fast.

Thanks again
Reply With Quote
  #6  
Old 08-18-2013, 10:28 AM
ZarrinPour ZarrinPour is offline
Senior Member
 
Join Date: Jul 2003
Posts: 231
Default

Hi
is it possible to change this code for using with CHROME browser??

Thanks.
Reply With Quote
  #7  
Old 08-20-2013, 11:57 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,297
Default

Not by using DDE:
stackoverflow
Reply With Quote
  #8  
Old 02-06-2018, 09:34 AM
golden_eyes golden_eyes is offline
Senior Member
 
Join Date: Dec 2005
Posts: 382
Default

Not working on FF quantum
Reply With Quote
  #9  
Old 02-06-2018, 10:23 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,297
Default

And what is not working?
The DDE implementation? Could be, DDE is somewhat deprecated (my oppinion)
You could always try a EnumWindows construction, for Chrome is a method in the link I provided in this thread. Shouldn't be that hard to translate to FF I guess
Reply With Quote
  #10  
Old 02-06-2018, 10:30 AM
golden_eyes golden_eyes is offline
Senior Member
 
Join Date: Dec 2005
Posts: 382
Default

The Firefox code is working well on Firefox up to 56 but in quantum which is above 58 can't catch the URL

Here is my code

Code:
procedure GetURL(var URL, Title: string); //IExplore, Netscape, Mosaic, Netscp6, Mozilla, Firefox
var
  oDDEClientConv: TDDEClientConv;
  sRequestData: string;
begin
  try
    try
      oDDEClientConv:= TDDEClientConv.Create(nil);

      with oDDEClientConv do begin
        if SetLink('firefox','WWW_GetWindowInfo') then
          sRequestData:= RequestData('0xFFFFFFFF,sURL,sTitle');

        if sRequestData <> EmptyStr then begin
          delete(sRequestData,1,1);
          URL := copy(sRequestData,1,pos('","',sRequestData)-1);
          delete(sRequestData,1,pos('","',sRequestData)+2);
          Title := copy(sRequestData,1,pos('"',sRequestData) - 1);
        end;
);

        CloseLink;
      end;
    finally
      oDDEClientConv.Free;
    end;
  except
    on E: Exception do
    MessageDlg('URL attempt failed! ' + sLineBreak +
                E.ClassName + ': ' + E.Message,mtError,[mbOK],0);
  end;
end;
Code:
procedure TForm1.Button3Click(Sender: TObject);
var
  sURL, sTitle: String;
begin
  GetURL(sURL, sTitle);

  ShowMessage(sURL + sLineBreak + sLineBreak + sTitle);
end;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 07:52 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.