• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

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.
0
cby1
Asked:
cby1
  • 5
  • 3
  • 2
1 Solution
 
AzraSoundCommented:
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
 
cby1Author Commented:
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
 
AzraSoundCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
cby1Author Commented:
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
 
AzraSoundCommented:
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
 
DennisBorgCommented:
BHO?
0
 
AzraSoundCommented:
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
 
DennisBorgCommented:
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
 
AzraSoundCommented:
Sorry I could not offer a more elegant solution...
0
 
cby1Author Commented:
No problem. It's obviously more involved than I thought. Thanks for your help.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now