get mouse events for active browser window with ActiveX

I need non-visual ActiveX component, which gets access to the mouse events, scrollbars and LocationURL of active Internet Explorer window. When user switches between windows, this component must follow him. I can enumerate windows with the following code, but how to find out which one is active:
  pvShell:=CoShellWindows.Create;
  for dwCount:=0 to (pvShell.Count-1) do begin
     ovIE:=pvShell.Item(dwCount); . . . .
KKostyaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

systanCommented:
unit unit1;

interface

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

type
   TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject) ;
    procedure Timer1Timer(Sender: TObject);
   private
   procedure ShowHwndAndClassName(CrPos: TPoint) ;
   public
   end;

var
   Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ShowHwndAndClassName(CrPos: TPoint) ;
var
   hWnd: THandle;
   aName,
   Text : array [0..255] of char;
begin
   hWnd := WindowFromPoint(CrPos) ;
   Label1.Caption := 'Handle : ' + IntToStr(hWnd) ;
   if boolean(GetClassName(hWnd, aName, 256)) then
     Label2.Caption := 'ClassName : ' + string(aName)
   else
     Label2.Caption := 'ClassName : not found';
   SendMessage(hWnd, WM_GETTEXT,
               SizeOf(Text), integer(@Text)) ;
   Label3.Caption := 'Text :' + Text;
end;

procedure TForm1.FormCreate(Sender: TObject) ;
begin
   Form1.FormStyle := fsStayOnTop;
   Timer1.Interval := 50;
end;

procedure TForm1.Timer1Timer(Sender: TObject) ;
var
   rPos: TPoint;
begin
   if boolean(GetCursorPos(rPos))
   then ShowHwndAndClassName(rPos) ;
end;

end.

//if i got it wrong, sorry, but if that helps you, then good luck
KKostyaAuthor Commented:
ok, it's good to get hWnd of the window, but how to get mouse events of that window?
systanCommented:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
    procedure MyMouseEvent(var Msg: TMsg; var Handled: Boolean);
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.MyMouseEvent(var Msg: TMsg; var Handled: Boolean);
var
  s : string;
begin
  case Msg.message of
    wm_LButtonDown: s := 'left mouse down';
    wm_LButtonUp:   s := 'left mouse up';
    wm_MouseMove:   s := 'mouse move';
    else            s := '';
  end;
  if s <> '' then
    ListBox1.Items.Insert(0, s);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := MyMouseEvent;
end;

end.



//other links
http://www.delphitricks.com/source-code/windows/trap_mouse_events_outside_of_my_application.html
http://delphi.about.com/od/vclusing/a/mouseadvanced.htm
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

KKostyaAuthor Commented:
thanks, but how to get mouse events not of Form1, but Internet Explorer window with hWnd handle?
systanCommented:
http://www.delphitricks.com/source-code/windows/trap_mouse_events_outside_of_my_application.html

How about that link, traps all mouse events in Internet Explorer or other windows
If that link doesn't help you of what you want, can you explain brieftly what you really want of the Internet Explorer?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KKostyaAuthor Commented:
this is what I need
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.