Solved

Catch back button click when automating IE

Posted on 2001-08-08
10
687 Views
Last Modified: 2012-06-22
Automating IE (InternetExplorer Object) from Visual Basic. I need to know when the user clicks the Back Button (Forward and Stop would be nice too - any toolbar button, ideally) on IE's toolbar.

I have not been able to find an event that would tell me when this occurs.
0
Comment
Question by:cby1
  • 5
  • 3
  • 2
10 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 6365092
The IE object does not exude an event to notify you of this...only of when it is navigating to a new page.  You could store the previous and next page URLs in variables, and check them in the IE object's BeforeNavigate event as a workaround.  However, this is not 100% accurate, obviously, as if someone typed in the URL of the page most recent in the history, you could not differentiate between them going back via the Back buttton, or directly by typing in the URL.

Your other options are to use a 3rd party component to subclass this automated instance of IE, and figure out which handle is sent which message when the buttons are clicked.  Or, create a BHO and perform the subclassing yourself.

BTW, why do you want to be notified of these events anyways?
0
 

Author Comment

by:cby1
ID: 6365140
AzraSound,

Thought of #1, and discarded for the reason you pointed out. Also, URLs sometimes get "transformed" during the nav, making the process of matching them with what you get in BeforeNavigate difficult. I suppose you could store the BeforeNavigate versions, and not the doc complete versions...

Was hoping to avoid anything as heavy (for me) as BHOs and subclassing. Was hoping for an API or something...

Why do I want this? I have a program that we use locally to track browser events for user testing purposes. It's useful to know not only that someone went to a page, but also how they got there. Same thing applies to the other buttons...
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6365167
In what way is the program/browser used?  Are you testing a website to see how people navigate through, or is it surfing in general?  If this is only for observational purposes, and the browser is launched via your program, have you considered creating a quick custom browser?  It would not take much time unless you were interested in all of the fancy properties IE, itself, possesses.
0
 

Author Comment

by:cby1
ID: 6365354
Yep, considered that option. We really didn't want to distract the user with the inevitable differences...but you have a point. We are most interested in testing website navigation and page layout.

I wonder how much work it would take to create a custom browser (using the Webbrowser control) that would look/feel enough like the standard IE to fool (or at least not bother) folks.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6365403
I think you would be surprised how quickly you could develop it, depending on all that you would want your browser to do, of course.  Providing navigation/home/print buttons are all one-liners in code.  You could create a fully functional browser in a day.  The only real considerations are how to handle certain scripts that may be run on a page, e.g., those that resize the browser window to some strange size after the window has been opened.   This will result in your browser control being resized, but not your main form.  These occurrences are rare, but I guess it is better to be aware of them.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:DennisBorg
ID: 6365467
BHO?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6365497
Hey Dennis,

BHO (Browser Helper Object)

It is essentially an in-process component that will start up with every instance of Internet Explorer.  IE will look in the registry for any components it should load here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects

You cant create a BHO directly with VB unless you have a type library exposing the necessary interfaces to you to do so.
0
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6365602
Thanks for the info, Azra. I had never heard nor seen that acronym before, and was trying to figure it out (Better Home Office, Biscuit and Honey Ordurv, etc)  ;-)


I understood what was trying to be accomplished, but didn't know what "BHO" stood for.

Thanks again.

-Dennis Borg
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6381291
Sorry I could not offer a more elegant solution...
0
 

Author Comment

by:cby1
ID: 6381311
No problem. It's obviously more involved than I thought. Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now