Prevent/Kill all Internet Explorer dialog boxes from VB

Posted on 2003-03-09
Medium Priority
Last Modified: 2007-12-19
I have an automated VB6 app which downloads web pages and then does a screen capture, before moving onto another page. However, the IE object will show busy=true indefinitely if a dialog or message box (e.g. password, question on frame support etc.) is opened and doesn?t receive input. I have tried setting silent=true, and tried the ?quit? browser method after a watchdog timeout and then restarting IE, however it won?t quit while a dialog is open.

I therefore need a dialog box killer either which prevents a dialog box opening, or kills it after a certain amount of time. All the freely available popup killers I have tried only kill new windows, not dialog and password boxes.

MS support say to try using Windows Hooks to automate the dialog windows as demonstrated for hooking the Print dialog box inside of IE at :

Has anybody tried this or any other approach?

Many thanks
Question by:Stevod
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8097730
One thought I have is.

Create a timer.
Set the interval for the timer to 1 second
In the timer event check what has focus.
If you do not want the form or dia;log open PostMessage to terminate.

You could even check the dialog caption after checking the focus to identifier expected Dialog Boxes and quit them rather than kill evverything that pops up.
LVL 16

Expert Comment

ID: 8097805

Expert Comment

ID: 8098703
As you say, test for a timeout in the busy state. You can then send a click to the default button on the dialogues, for example using the code at http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=198 (which you can use for the snapshot too).

For a similar question, check out http://beta.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20510962.html

A different option would be to consider using the Internet Transfer Control to get the HTML, and then editing the code to hack out all the offending scripts and so on. (Alternatively by carefully changing all the 'alert=' strings to 'document.title=' etc.) You then write your updated code into the browser. The problem here is that any relatively referenced images (and other dependent files) will not appear, so you would also have to re-write the relative hrefs and absolute hrefs.

Kindest regards,
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8098714
...typo: I meant to say 'so you would also have to re-write the relative hrefs AS absolute hrefs.'


Expert Comment

ID: 8098973
Here's a first approximation to a solution. I have a form with a listbox (List1, just somewhere to stick the list of URLs) and a timer (Timer1). Paste the code below. Add a module with the code from http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=198 , and reference Microsoft Internet Controls.

Kindest regards,

Dim IE As New SHDocVw.InternetExplorer
Dim timeOut As Integer

Private Sub Form_Load()
With List1
.AddItem "http://www.google.com"
.AddItem "http://www.javascriptcity.com/scripts/local/ex/ex16.htm"  'contains 3 alerts
.AddItem "http://www.yahoo.com"
End With

Set IE = New InternetExplorer
IE.Visible = True

Timer1.Interval = 2000
Timer1.Enabled = True


End Sub

Private Sub GetSites()

For n = 0 To List1.ListCount - 1
timeOut = 0

IE.Navigate2 (List1.List(n))
Do While IE.ReadyState <> READYSTATE_COMPLETE 'Wait until page is loaded

If timeOut > 5 Then 'Too long. There must be a popup.
IE.Visible = True 'Make sure focus is set on browser
VbSendKeys ("{ENTER}")
timeOut = 0
End If


VbSendKeys ("{SNAPSHOT}") 'Take a snapshot
'Code to save the snapshot from clipboard here

Next n

Timer1.Enabled = False

End Sub

Private Sub Timer1_Timer()
timeOut = timeOut + 1
End Sub

Expert Comment

ID: 8900456
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 9074505
Stevod, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer

Accepted Solution

YensidMod earned 0 total points
ID: 9165933
Question is PAQ'd and no points refunded.

Community Support Moderator @Experts Exchange

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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