Solved

Catch back button click when automating IE

Posted on 2001-08-08
10
689 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

829 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