Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Firefox get url from all tabs


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 7, 2018 3:36 PM Last Post By: Rael Bauer
pss edn

Posts: 45
Registered: 1/13/04
Firefox get url from all tabs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 10:02 AM
Using XE7
I need to open a new tab in FireFox if my URL is not present, and if it is present, bring FireFox to the top.
Using DDE, I can get the URL from the active tab, but not all:
   SetLink(Browser, 'WWW_GetWindowInfo');
   temp := RequestData('0xFFFFFFFF');

So, I am trying to find all windows with the FireFox class name 'MozillaWindowClass', and then get the url from it.
Using Spyxx and Winspector, I can get the existing FireFox classes, but I do not know how to get the class name for the control in each tab that contains the URL.
For simplicity, this is part of the code that I am using in my EnumWindows to capture the window text of the FireFox classes, but not the URL text.

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


For the second part of the question, I can not find a way to bring FireFox to the top.
Using Spyxx, I see that the main FireFox window has an extended flag of TOPMOST, so, using classic ways to bring window to the top does not work.
  ShowWindow(mlhWnd, SW_SHOW);
  SetForegroundWindow(mlhWnd);


So my questions are:
How can I get the URLs from all open tabs in Firefox, and how can I bring FireFox window to the top.
Matt Jacks

Posts: 1
Registered: 8/23/07
Re: Firefox get url from all tabs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2018 2:15 AM   in response to: pss edn in response to: pss edn
I'm using the following code to capture the URL from Firefox, but itsn't working on FF Quantum

I'm currently running on FF 56 64-Bit
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;


procedure TfrmMain.Button3Click(Sender: TObject);
var
  sURL, sTitle: String;
begin
  GetURL(sURL, sTitle);
 
  ListBox1.Items.Add(sURL);
ListBox1.Items.Add(sTitle);
end;


Do you have any idea on how to fix it to meet quantum?
Rael Bauer

Posts: 228
Registered: 10/10/02
Re: Firefox get url from all tabs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2018 3:36 PM   in response to: Matt Jacks in response to: Matt Jacks
Do you have any idea on how to fix it to meet quantum?

It looks like DDE Client is not supported in FF quantum. You can achieve this with .net and UI automation (search on stackoverflow). Create a .net dll and then call that dll from Delphi.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02