?
Solved

How to grab URLs from all open browser windows sessions?

Posted on 2003-03-01
18
Medium Priority
?
199 Views
Last Modified: 2010-04-04
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
Comment
Question by:terena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
18 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8048304
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
 

Author Comment

by:terena
ID: 8048636
I don't think this method enables me to get URLs from all open windows of a browser. Or does it?
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 8050876
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Accepted Solution

by:
ginsonic earned 280 total points
ID: 8050888
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
 

Author Comment

by:terena
ID: 8051205
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
 

Author Comment

by:terena
ID: 8051239
And how do I get the title of the window?
Thanks.
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 8051250
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
 
LVL 9

Expert Comment

by:ginsonic
ID: 8051267
The last tip return the page title, too.
0
 

Author Comment

by:terena
ID: 8051273
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
 

Author Comment

by:terena
ID: 8051279
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
 

Author Comment

by:terena
ID: 8051280
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 

Author Comment

by:terena
ID: 8051283
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 

Author Comment

by:terena
ID: 8051284
Well, in fact GetWindowText seems to work but it also grabs the - Microsoft Internet Explorer termination...
0
 

Author Comment

by:terena
ID: 8081035
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
 
LVL 9

Expert Comment

by:ginsonic
ID: 8086187
Are you sure that is a C answer ? :(
0
 

Author Comment

by:terena
ID: 8087420
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
 
LVL 9

Expert Comment

by:ginsonic
ID: 8088630
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
 
LVL 1

Expert Comment

by:Computer101
ID: 8091748
Grade changed as requested

Computer101
E-E Admin
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question