Solved

Catch back button click when automating IE

Posted on 2001-08-08
10
686 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 68
Updates not working for MS Windows 7 12 126
How to debug this code 7 51
Using "ScreenUpdating" 6 45
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

23 Experts available now in Live!

Get 1:1 Help Now