Solved

Reading the ie addressline content from a second program

Posted on 2004-03-26
8
193 Views
Last Modified: 2011-09-20
Hello !
I'm working with delphi 5 and Win98/XP.
Is it possible to read the actual content of browser address-lines (netscape and ie) from a second program (my delphi app) running in the background when doing a button-click there?
If someone have a few code lines or a link for additional help for me i'll be very happy!
Thanks a lot!
Best regards,
Ingo
0
Comment
Question by:Ogni
[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
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10689945
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10689968

The link i provided, should do it for you, but you can also check out this site:

http://www.euromind.com/iedelphi/index.htm

for other IE related issues:

Shane
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 100 total points
ID: 10690938
I tested this with IE and it works, I don't have NS installed but this should work for it as well.

// For IE:
procedure GetIEInfo(var sURL: String; var sTitle: String);
var
  DDE:TDDEClientConv;
  sInfo: String;
  slInfo: TStringList;
begin
  slInfo := TStringList.Create;
  try
    DDE:=TDDEClientConv.Create(nil);
    try
      if DDE.SetLink('IExplore','WWW_GetWindowInfo') then
        slInfo.CommaText := DDE.RequestData('0xFFFFFFFF');
    finally
      DDE.Free;
    end;
  finally
    sURL := slInfo[0];
    sTitle := slInfo[1];
    slInfo.Free;
  end;
end;

//For Netscape:
procedure GetNetscapeInfo(var sURL: String; var sTitle: String);
var
  DDE:TDDEClientConv;
  sInfo: String;
  slInfo: TStringList;
begin
  slInfo := TStringList.Create;
  try
    DDE:=TDDEClientConv.Create(nil);
    try
      if DDE.SetLink('Netscape','WWW_GetWindowInfo') then
        slInfo.CommaText := DDE.RequestData('0xFFFFFFFF');
    finally
      DDE.Free;
    end;
  finally
    sURL := slInfo[0];
    sTitle := slInfo[1];
    slInfo.Free;
  end;
end;

//Usage:
procedure TForm1.Button1Click(Sender: TObject);
var
  sURL, sTitle: String;
begin
  GetIEInfo(sURL, sTitle);
  Memo1.Lines.Clear;
  Memo1.Lines.Add(sURL);
  Memo1.Lines.Add(sTitle);
  GetNetscapeInfo(sURL, sTitle);
end;
0
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!

 
LVL 26

Expert Comment

by:EddieShipman
ID: 10690944
Oh,

uses ..., DDEMan;
0
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 100 total points
ID: 10691058
This code will retrieve the address from ALL IE instances (more than one IE open)

place a button and listbox on your form


function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
begin
    //try to get a handle to IE's toolbar container
    hWndIEChild := FindWindowEx(hWndIE, 0, 'WorkerW', nil);
    if hWndIEChild > 0 then
    begin
      //get a handle to address bar
      hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ReBarWindow32', nil);
      if hWndIEChild > 0 then
      begin
        //finally, locate combo box and add its text to the list
        hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBoxEx32', nil);
        if hWndIEChild > 0 then
        begin
          SendMessage(hWndIEChild, WM_GETTEXT, 255, integer(@Buffer));
          //List.AddObject(Buffer,TObject(hWndIE));
          List.Add(Buffer)
        end;
      end;
    end;
  end;
  //continue enumeration
  Result :=True;
end; (*GetUrlFromIE*)


procedure TForm1.btnRefreshClick(Sender: TObject);
begin
 listbox1.Clear;
 EnumWindows(@GetUrlFromIE, LParam(listbox1.Items));
end;


Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10691076
The GetUrlFromIE function is declared in the interface section as
 
function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
 
This function is an application-defined callback function that receives top-level window handles as a result of a call to the EnumWindows.

Again, this is all laid out in a very nice example here:
http://delphi.about.com/library/weekly/aa060303a.htm

Shane
0
 

Author Comment

by:Ogni
ID: 10698138
Hi Eddie, hi Shane,

Thanks a lot for your help!!!
I think splitting the points is fair.

Best regards,
Ingo
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 10698558
You did say from both NS and IE, right?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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