Solved

Iexplorer event sinking

Posted on 2004-10-19
8
493 Views
Last Modified: 2010-04-05
Hello Experts.

 Ive looked through many solutions from the last 4 yrs and was wondering how one would set a hook to monitor everytime the default browser is opened (created process) and the listboxEx contains text (Uniform Resource Locator). I downloaded the EventSinkImp utility delphi unit and it seems to work great on IE except it involves you to physically invoke the browser in order to connect() to it and monitor it's events/msg's via pressing of a button. Are there any solutions that only monitor links in the address bar which then immediately report to your delphi app? I dont want to have to click a button to monitor something, everytime a new window of IE opens I want it to report the URL or everytime the text changes I want it to add to a list of already listed URLs. The event sink component seems to work great but I do NOT want to have to press a button everytime I run it to launch IE. You can download the component and demo here
http://www.techvanguards.com/files/IE4SinkDemo.zip

 I'm open to any coding techniques which does NOT require you to click a button to start the message event listening on the browser. I'd like to hook it in some fashion to avoid user interaction (pressing of a button).

 Regards,
    Alloc
0
Comment
Question by:alloc
[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
  • 5
  • 3
8 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 12358573
Run the code in the button click in the FormShow, DUH!

Now, what if someone's default browser is FireFox or Opera, or Netscape, or Mozilla? How do you plan on getting those URLs?
0
 

Author Comment

by:alloc
ID: 12362504
EddieShipman,
Well Ive already tried that, I'm not that clueless, and what happens is the demo project requires the code under the button click event to execute the browser in order to sink it's messages. In other words it opens the browser and I dont want to do this. I only want to execute IExplorer.exe directly rather than through my project code to have it auto-hook these messages.

And in regards to "what if someone's default browser is FireFox or Opera, or Netscape, or Mozilla? How do you plan on getting those URLs?" I'm only mainly concerned about Ineternet Explorer at this point in time.

 Thanks,
  Alloc
0
 

Author Comment

by:alloc
ID: 12373971
Maybe it would be better to use this funtion on a timer:

function Get_URL(Servicio: string): String;
var
 Cliente_DDE: TDDEClientConv;
begin
  Result := '';
  Cliente_DDE:= TDDEClientConv.Create( nil );
  with Cliente_DDE do
    begin
      SetLink( Servicio,'WWW_GetWindowInfo');
      Result := StrPas(RequestData('0xFFFFFFFF'));
      CloseLink;
    end;
  Cliente_DDE.Free;
end;

// And call it with Get_Url('IExplore');

And to avoid repeats filter the returned strings (URLs) in a stringlist then place them into a listbox so that I only get new Urls and not repeated (idle) pages left open in the browser.

 Would this work, or would it be better to hook the browser using event sinking? I'm open to suggestions and could use an example or a decent string compare function for what I want to do.
 
Thanks,
 Alloc
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!

 

Author Comment

by:alloc
ID: 12398071
hello?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 12399846
If you do that, you need to have it in a separate thread as it will hog resources and possibly run the CPU% to a high level.

I'm going to take the eventsink demo and do something that I just thought of. I'll get back with you.
0
 

Author Comment

by:alloc
ID: 12403437
Ok, yea I imagine it would do that
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 12403912
OK, I was able to use IShellWindows to connect to an already open instance of IE. No button clicking necessary.

Here's how I did it:

procedure TForm1.FormShow(Sender: TObject);
var
  ShellWindow: IShellWindows;
  spDisp: IDispatch;
  k: Integer;
begin
  try
    // get the running instance of Internet Explorer
    ShellWindow := CoShellWindows.Create;
    for k := 0 to ShellWindow.Count do
    begin
      spDisp := ShellWindow.Item(k);
      if spDisp = nil then Continue;
      // QueryInterface determines if an interface can be used with an object
      spDisp.QueryInterface(IWebBrowser2, FIE);
      { tell IE that DWebBrowserEvents21 wants to start receiving events }
      DWebBrowserEvents21.Connect(IUnknown(FIE));
      FIE.Visible := True;
      FIE.GoHome;
    end;
  except
    ShowMessage ('Unable to establish connection with Internet Explorer. Make sure you have IE4 installed!');
  end;  { except }
end;

Now you can do whatever you want. I do not know how to continually check to see if the IShellWindows collection
changes. That would be a different question altogether. Good luck...
0
 

Author Comment

by:alloc
ID: 12405243
k I'll mess with it thanks...
Might post again about this subject in the future if I cannot resolve a way to update the listbox.

Alloc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

615 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