Click here to Skip to main content
Click here to Skip to main content

IE Advanced Toolbar for Favorite site navigation and log-in

, 23 Jan 2005
Rate this:
Please Sign up or sign in to vote.
Advanced IE toolbar, using .NET band objects, for navigation and login with a single click.

Sample Image - IE_Advanced_Toolbar.jpg

Introduction

When you want to access your yahoo mail account, you go to mail.yahoo.com, type in your user name and password and click "Sign In" button. You can select Remember my ID on yahoo to save typing user name but still this is too much of work. If you switch to a different machine you will have to do it again. In this article, I will show you how to add a toolbar to Internet Explorer which will navigate to your favorite Web site(mail.yahoo.com) and do the login for you. Copying some files to other machine will add the toolbar buttons on other machine as well.

Background

Basic framework for this tutorial for adding toolbar to Internet Explorer is copied from Pavel Zolnikov's article on band objects. I suggest you to read this article to understand BandObjects and how you can add Explorer Bar /Toolbar to Internet Explorer. I extended his SampleBar to add auto-login functionality.

Using Toolbar

You can either use the setup.exe for setting up the toolbar on your machine or you can download the source code and build the project. Once you have this toolbar in IE, you can navigate to your favourite website for which you want single click login, say mail.yahoo.com.

  1. Click on Customize button of the toolbar which will bring up a Customize form with all the links, and controls in this website.
  2. In Button Title/Tooltip edit control, enter for the button title for this website, say xyz@yahoo.
  3. In the list box, you will see the entry login. Select it and enter your login name in value edit control and select Add button (Action for entering your username).
  4. Select passwd and enter your password and select Add button (Action for entering your password).
  5. Select Sign In and select Add button (Action for clicking on Sign In button).
  6. Select Ok button to make this button entry to IE toolbar.

Now whenever you click on this button, first IE will navigate to mail.yahoo.com and login in with above login details. The user name, password you entered are kept in an XML file in C:\IE AutoComplete directory. This is a simple text file so username and password are not protected, please don't use this toolbar for your banking websites. I have not added any encryption to it but if you want to modify the source code, then do it.

To remove any button entry from the toolbar, delete the respective file from C:\IE AutoComplete directory. To add these same entry to other computer just copy this directory contents. Toolbar reads all the files in this directory to create configurated buttons.

Using the code

  1. I used Extending Explorer with Band Objects using .NET and Windows Forms to create a user control which will host IE toolbar. I modified Pavel Zolnikov 's SampleBars.sln. In HelloWorld class, button1 is replaced with a ToolBar control myToolBar.
  2. Reference to Microsoft.mshtml.dll is necessary to access HTMLDocumentClass, HTMLAnchorElementClass, IHTMLInputElement. Also put the following lines at the beginning of HelloWorldBar.cs:
    using mshtml;
  3. A Customize button is added to this toolbar. The click event of this toolbar will iterate through active document to collect all the links, buttons, and input boxes on page. Explorer.Document is instance of currently loaded HTMLDocumentClass.
    //Explorer.IWebBrowser_Document. HTMLDocumentClass doc = 
          (HTMLDocumentClass)Explorer.Document;

    Two classes ItemType and ButtonEntry are defined in Interface.cs file. ItemType class instance is used for item details on a webpage. ButtonEntry class is used to read/write customized XML button entry data to file system. All these HTMLAnchorElementClass and HTMLInputElementClass objects are added to customize Items' ArrayList of type ItemType. Customize form is displayed for user input.

    private void onCustomize(object sender, System.EventArgs e)
    {
      //Explorer.IWebBrowser_Document. HTMLDocumentClass doc = 
      //           (HTMLDocumentClass)Explorer.Document;
       
      Customize frm = new Customize(); 
      frm.URL = doc.url; int count = -1; 
      foreach(object o in doc.all)
      {
        try
        {
          count++;
          if( !(o is IHTMLElement))
          {
            continue;
          } 
          IHTMLElement elem = (IHTMLElement)o; 
          if(elem.id == null)
          { 
            if(o is HTMLAnchorElementClass)
              {
                try
                {
                  HTMLAnchorElementClass aElem = (HTMLAnchorElementClass)o;
                  string id = aElem.outerText;
                  string itemInfo = "outterText"; 
                  if(id == null)
                  {
                    id = aElem.href; itemInfo = "href";
                  } 
                  frm.Items.Add(new ItemType("link",id,itemInfo));
                           
                } 
                catch(Exception /*ex_in*/)
                {
                  sp;        
                  {
                    //MessageBox.Show(ex_in.ToString(),"Exception");
                  }
                       
                  continue;
                }
              } 
              if(o is IHTMLInputElement)
              {
                HTMLInputElementClass btn = (HTMLInputElementClass)o;
                try
                {
                  if(btn.type != null)
                  {
                    string type = btn.type.ToLower(); 
                    if(type=="submit" || type == "button" || type == "radio" 
                                 || type == "checkbox" || type == "text" 
                                 || type == "password" )
                    {
                      string id = btn.id;
                      string itemInfo = "id";
                      if(id == null)
                      {
                        id = btn.id; itemInfo = "id";
                      } 
                      if(id == null)
                      {
                        id = btn.name; itemInfo = "name";
                      }
                      string defaultVal = btn.defaultValue; 
                      if(defaultVal != null)
                      { 
                        defaultVal = defaultVal.Trim(); 
                        if(defaultVal == "")
                        { 
                          defaultVal = id;
                        }
                      } 
                      frm.Items.Add(new ItemType(type,id,itemInfo,defaultVal));
                      continue;          
                      continue;
                    }
                  }
                } 
                catch(Exception /*ex_in*/)
                {
                  //MessageBox.Show(ex_in.ToString(),"Exception");
                };       
              }
            }
          } 
          catch(Exception /*eee*/)
          {
            //MessageBox.Show(eee.ToString());
          }
        } 
        if(frm.ShowTheDialog() == DialogResult.OK)
        { 
          addBtn(frm.myButtonEntry);
        };   
      }
       
      return;
    }
  4. On any other button click (xyz@yahoo), if active page is different than mail.yahoo.com, then mail.yahoo.com is loaded. Values are set for all the controls, and any submit button action is invoked to login to particular website.
    private void myToolBar_ButtonClick(object sender, 
                System.Windows.Forms.ToolBarButtonClickEventArgs e)
    {
      if(myToolBar.Buttons.IndexOf(e.Button) == 0)
      {
        onCustomize(null,null);
        return;
      }
    
      ButtonEntry btnEntry = (ButtonEntry)e.Button.Tag;
    
      onButtonClick(btnEntry);
    }
    
    protected void onButtonClick(ButtonEntry frm_in)
    {
      //Explorer.IWebBrowser_Document.
      HTMLDocumentClass doc = (HTMLDocumentClass)Explorer.Document;
    
      //check for correct site.
      if(frm_in.myURL != doc.url)
      {
        try
        {
          doc.url = frm_in.myURL;
        }
        catch(Exception /*e_in*/)
        {
          //MessageBox.Show(e_in.ToString(),"Exception Caught");
          return;
        }
        Explorer.DocumentComplete+= 
           new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(
           Explorer_DocumentComplete);
        myPendingReqest = frm_in;
        return;
      }
    
      //for each item in UserList fill the values on the active page.
      foreach(ItemType it in frm_in.myArrayLst)
      {
        if(it.Type == "text" || it.Type == "password" )
        {
          try
          {
            //get the item by id.
            HTMLInputElementClass ele = (
                HTMLInputElementClass)doc.getElementById(it.Name);
    
            ele.value = it.Val;
          }
          catch(Exception /*e_e*/)
          {
            //MessageBox.Show("getElementById failed." + e_e.ToString());
          }
        }
        else if(it.Type == "radio" || it.Type == "checkbox" )
        {
          try
          {
            //get the item by id.
            HTMLInputElementClass ele = 
                (HTMLInputElementClass)doc.getElementById(it.Name);
    
            ele.@checked = Convert.ToBoolean(it.Val);
          }
          catch(Exception /*e_e*/)
          {
            //MessageBox.Show("getElementById failed." + e_e.ToString());
          }
        }
        else if(it.Type=="submit" || it.Type == "button")
        {
          try
          {
            //get the item by id.
            HTMLInputElementClass ele = 
               (HTMLInputElementClass)doc.getElementById(it.Name);
            ele.click();
          }
          catch(Exception /*e_e*/)
          {
            //MessageBox.Show("getElementById failed." + e_e.ToString());
          }
        }
      }//end of foreach(string userReq in frm_in.UserListBox)
    }
    

Pavel Zolnikov's article shows the important part of adding IE toolbar. This article adds feature to modify the IE functionality. As you can see, Accessing/modifying HTML page content from client side is very simple and easy.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

vadaa

United States United States
No Biography provided

Comments and Discussions

 
GeneralPlease Help - Imposible to build example Interop.SHDcoVw reference to a not safe name PinmemberMember 507259823-May-11 0:51 
GeneralDoesn't display Pinmemberunderscore_dot11-Jan-10 22:04 
QuestionHow to Get Yahoo mail Inbox Message Title PinmemberDabara18-Jun-08 3:55 
Questiontoolbars Pinmemberhjvgbjhv8-Jun-08 19:29 
QuestionHow to make the toolbar detect mouse clicks on html buttons automatically Pinmembermanum3-Jun-08 8:23 
GeneralToolbar not displayed Pinmembersathish1518-Oct-07 3:37 
GeneralRe: Toolbar not displayed Pinmemberangelyaya17-Jul-08 23:40 
GeneralOnDocumentComplete Pinmembermikemcmeekin4-Apr-07 7:02 
GeneralRe: OnDocumentComplete Pinmembercfenvey3-Apr-08 5:16 
QuestionIE Toolbar show up automatically after installing toolbar. Pinmemberpeerahmad3-Apr-07 0:35 
GeneralCustom Toolbar Button Pinmember101629-Mar-07 3:00 
QuestionAnyone achieved it? PinmemberALBERTOPAG18-Feb-07 22:31 
GeneralToolBar Installation PinmemberRaja Satpathy18-Sep-06 20:06 
GeneralIE 7: toolbar unmovable! Pinmemberjoebarthib12-Jun-06 3:13 
GeneralRe: IE 7: toolbar unmovable! PinmemberMXX23-Oct-06 5:45 
GeneralToolbar location Pinmembermagdas6-Feb-06 2:44 
Questionwhere is xml file? Pinmembershyang@amc.seoul.kr20-Jul-05 13:20 
QuestionCan you done this job like RoboForm? Pinmembercjwn15-Jul-05 20:39 
GeneralDeployment of IE Advanced Toolbar PinsussAnonymous5-Jul-05 7:55 
GeneralRe: Deployment of IE Advanced Toolbar PinsussAnonymous6-Jul-05 8:31 
GeneralRe: Deployment of IE Advanced Toolbar PinsussAnonymous17-Jul-05 22:31 
GeneralRe: Deployment of IE Advanced Toolbar Pinmember101631-Aug-07 22:00 

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 23 Jan 2005
Article Copyright 2005 by vadaa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid