Link to home
Start Free TrialLog in
Avatar of cby1
cby1

asked on

Catch back button click when automating IE

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.
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cby1
cby1

ASKER

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...
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.
Avatar of cby1

ASKER

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.
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.
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.
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
Sorry I could not offer a more elegant solution...
Avatar of cby1

ASKER

No problem. It's obviously more involved than I thought. Thanks for your help.