Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

Prevent/Kill all Internet Explorer dialog boxes from VB

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 :
http://msdn.microsoft.com/workshop/browser/wb_print.asp

Has anybody tried this or any other approach?

Many thanks
Stevod
0
Stevod
Asked:
Stevod
1 Solution
 
JohnMcCannCommented:
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.
0
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
RhaedesCommented:
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,
Rhaedes
0
Independent Software Vendors: 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!

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

Rhaedes
0
 
RhaedesCommented:
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,
Rhaedes


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

GetSites

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
DoEvents

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

Loop

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
0
 
CleanupPingCommented:
Stevod:
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?
0
 
DanRollinsCommented:
Stevod, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 
YensidModCommented:
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now