Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

How to grab URLs from all open browser windows sessions?

This question was given some answers but not complete ones. I need a solution that should be able to grab URLs from all the open Windows of a browser, unlike the DDE solution. Thanks.
0
terena
Asked:
terena
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

What's about COM way?, I like it more than DDE

uses SHDocVw;

procedure TForm1.Button1Click(Sender: TObject);
var
 IE : TInternetExplorer;
begin
 IE := TInternetExplorer.Create(self);
 SHowMessage(IE.LocationURL);
 IE.Free;
end;

and here's another way
www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20161967
0
 
terenaAuthor Commented:
I don't think this method enables me to get URLs from all open windows of a browser. Or does it?
0
 
ginsonicCommented:
uses
  shdocvw_tlb;
   
procedure TForm1.Button2Click(Sender: TObject);
var
  x: Integer;
  Sw: IShellWindows;
begin
  sw := CoShellWindows.Create;
  for x := 0 to SW.Count - 1 do
    Listbox1.Items.Add((Sw.Item(x) as IWebbrowser2).LocationUrl);
end;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ginsonicCommented:
Or better:

unit Unit1;

interface

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

type
TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;

  procedure Button1Click(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

function GetIEEditText(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
GetClassName(wnd, wndClass, SizeOf(wndClass));
if wndClass = 'Edit' then
begin
  SendMessage(wnd, EM_SETSEL, 0, -1);
  SendMessage(wnd, WM_COPY, 0, 0);
  SendMessage(Param, WM_PASTE, 0, 0);
  SendMessage(Param, WM_CHAR, 13, 0);
  Result := False;
end else
  Result := True;
end;

function GetIEAddres(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
GetClassName(wnd, wndClass, SizeOf(wndClass));
if wndClass = 'ComboBoxEx32' then
begin
  EnumChildWindows(wnd, @GetIEEditText, Param);
  Result := False;
end else
  Result := True;
end;

function FindIExplorer(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
GetClassName(wnd, wndClass, SizeOf(wndClass));
if wndClass = 'IEFrame' then
  EnumChildWindows(wnd, @GetIEAddres, Param);
Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@FindIExplorer, Memo1.Handle);
end;

end.
0
 
terenaAuthor Commented:
It's perfect; the points are yours. do you know if it works for Opera or Netscape (i tried wsing winsight but i couldn't identify the classes to get to the combobox)
0
 
terenaAuthor Commented:
And how do I get the title of the window?
Thanks.
0
 
ginsonicCommented:
I tested and don't work for Opera or Netscape. But can use ddeman and search these browsers as services.

http://www.swissdelphicenter.ch/torry/showcode.php?id=198

0
 
ginsonicCommented:
The last tip return the page title, too.
0
 
terenaAuthor Commented:
Well, i could never use DDE for multiple open windows.

I tried GetWindowText(wnd,
but it didn't work if there were more than one open windows (in your first tip)
0
 
terenaAuthor Commented:
Well, i could never use DDE for multiple open windows.

I tried GetWindowText(wnd,
but it didn't work if there were more than one open windows (in your first tip)
0
 
terenaAuthor Commented:
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 
terenaAuthor Commented:
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 
terenaAuthor Commented:
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 
terenaAuthor Commented:
Well, I wanted a solution to work with all browsers, and with all their open windows; but it seems that this is the best I can get.
0
 
ginsonicCommented:
Are you sure that is a C answer ? :(
0
 
terenaAuthor Commented:
Sorry, I'm new to EE and I didn't know that average (which should be quite good) means C :-|
Can I change that at least to a B?
0
 
ginsonicCommented:
If you wish this, can go to Community Support and ask ( put a 0 points question there) to change the average (don't forget to type this URL).

Is better to appreciate corect the comments before offer a grade(don't cost you more points as you offer initial) else the experts will step your further questions.

Isn't a points problem, but the prestige for a good history here at Ex-Ex :)

Best regards,
Nick
0
 
Computer101Commented:
Grade changed as requested

Computer101
E-E Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now