Click here to Skip to main content
Licence CPOL
First Posted 29 Oct 2005
Views 72,519
Downloads 781
Bookmarked 44 times

Internet Explorer Activity Monitor

By | 29 Oct 2005 | Article
The Internet Activity Monitor captures what you are doing on Internet Explorer like opening a browser, requesting a Website and closing the browser.
Sample image

Introduction

This application is a simple but useful one. I used this application in a Windows Service which monitors the activity of the browser and the person logged-in at that time.

Adding Reference

Sample Image - IE_Activity_Monitor.jpg

Add a reference in your project to SHDocVw.dll. This is a COM component named Microsoft Internet Controls. It contains the definitions of the InternetExplorer and ShellWindows classes.

About the Code

The code can be divided into three parts:

  1. Browser Open Activity
  2. Browser Navigation Activity
  3. Browser Close Activity

Following are the event handlers that are fired at their respective events:

// THIS EVENT IS FIRED WHEN A NEW BROWSER IS OPENED
        private void shellWindows_WindowRegistered(int z)
        {            
            string filnam;        
            
            foreach (SHDocVw.InternetExplorer ie in shellWindows)
            {
                filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
    
                if (filnam.Equals("iexplore"))
                {
                    browser = ie;    
                        
                    bool check=true;

                    for (int i=0; i<Current_IE_Handles.Count; i++)
                    {
                        if (Current_IE_Handles[i].ToString()==browser.HWND.ToString())
                        {
                            check=false;
                        }
                    }
                        
                    if (check==true)
                    {
                        Current_IE_Handles.Add(browser.HWND.ToString());
                        this.listBox1.Items.Add("Browser Open : Handle
					( "+browser.HWND.ToString()+" )");
                        browser.BeforeNavigate2+=
			new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler
			(browser_BeforeNavigate2);
                    }                        
                }
            }            
        }

When you type something like www.codeproject.com, this event is fired and here you can capture all the information about the Internet Explorer Navigation.

// THIS EVENT IS FIRED WHEN THE BROWSER IS JUST ABOUT TO NAVIGATE TO A WEBSITE
        private void browser_BeforeNavigate2(object a,ref object b,
		ref object c,ref object d,ref object e,ref object f,ref bool g)
        {
            this.listBox1.Items.Add(browser.HWND.ToString()+ " : "+b.ToString());
        }
// THIS EVENT IS FIRED WHEN A NEW BROWSER IS CLOSED
        private void shellWindows_WindowRevoked(int z)        
        {            
            string filnam;
            ArrayList Closed_IE=new ArrayList();
              
            foreach (SHDocVw.InternetExplorer ie in shellWindows)
            {
                filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
    
                if (filnam.Equals("iexplore"))
                {
                    Closed_IE.Add(ie.HWND.ToString());
                }
            }    
        
            for (int i=0; i<this.Current_IE_Handles.Count; i++)
            {
                bool check=false;

                for (int j=0; j<Closed_IE.Count; j++)
                {
                    if (Convert.ToInt32(this.Current_IE_Handles[i])==
			Convert.ToInt32(Closed_IE[j]))
                        check=true;
                }

                if (check==false)
                {
                    this.listBox1.Items.Add("Browser Closed : Handle
			( "+this.Current_IE_Handles[i].ToString()+" )");
                    this.Current_IE_Handles.RemoveAt(i);
                    break;
                }
            }
        } 

Currently this application captures the activity of the Internet Explorer. A new and improved version will be posted shortly that can monitor the activity of user defined browsers.

Initial Work

I carried forward the work done by Steven M. Cohn. Check out his post at this link.

History

  • 29th October, 2005: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ali Raza Shaikh

Software Developer

Pakistan Pakistan

Member

Ali Raza Shaikh did his BS (CS) from FAST-NUCES, Karachi Campus. He is also a Microsoft Certified Application Developer. He have a great passion for programming and all the programming related stuff. He can be reached at alirazashaikh.blogspot.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralHTTP monitor PinmemberGlobalization6:49 15 Oct '08  
GeneralException occur while code placed in a window service PinmemberMember 33036792:47 28 May '08  
GeneralRe: Exception occur while code placed in a window service PinmemberHimal Rupera0:00 19 Jun '08  
QuestionIE 7 Tabbing, How can you make this work with tabs?? PinmemberMember 313260513:52 23 Mar '08  
AnswerRe: IE 7 Tabbing, How can you make this work with tabs?? PinmemberMember 33036790:17 21 Jun '08  
QuestionWindows Service PinsussF.Granata21:07 20 Dec '07  
GeneralMonitor all application Pinmemberparvu20041:39 3 Nov '07  
QuestionInternet Explorer 7 Pinmemberfredamaral9:26 22 May '07  
QuestionIE Protected Mode on Vista PinmemberPappu5star0:49 2 Apr '07  
GeneralComparing this with Joe Bergeron's PinmemberFresh Mexican Food Fan8:19 21 Mar '07  
GeneralPopup PinmemberTadas Danielius23:54 10 Nov '06  
Generalother browsers.. PinmemberAAndrews8:37 22 Jul '06  
Generalstops in some conditions PinmemberRupeshV18:16 15 May '06  
GeneralCannot Run As a Windows Service Pinmemberdnan20:41 25 Apr '06  
GeneralRe: Cannot Run As a Windows Service Pinmemberscippyone7:36 18 May '07  
Generalsetting the code into a dll PinmemberRupeshV20:26 10 Apr '06  
Generalnice Pinmemberpunkcpp19:17 29 Mar '06  
GeneralRe: nice Pinmemberpunkcpp19:19 29 Mar '06  
Questioncan you make it better Pinmemberpennamaraju17:38 18 Jan '06  
AnswerRe: can you make it better PinmemberAli Raza Shaikh22:27 28 Jan '06  
GeneralRe: can you make it better PinmemberJack98762:52 22 Feb '10  
GeneralBUG whan open more windows PinmemberEmailSolidale22:54 22 Nov '05  
GeneralRe: BUG whan open more windows PinmemberAli Raza Shaikh22:30 28 Jan '06  
GeneralRe: BUG whan open more windows PinmemberTadas Danielius2:59 11 Nov '06  
GeneralRe: BUG whan open more windows Pinmemberscippyone5:22 6 May '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 29 Oct 2005
Article Copyright 2005 by Ali Raza Shaikh
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid