Jump to content

AutoIT script to handle Internet explorer crash dialog


Recommended Posts

I have an autoIT script that does the following

1)wait for the IE crash dialog. There are two kinds of ie crash dilalogs

first one has text similar to "Internet explorer has encountered a problem and needs to shutdown.." and has a close button.

the second one has similar text but is bigger in size and has Send and Don't Send buttons.

2) Click the Close or Don't Send button respectively depending on the ie crash dialog that pop's up.

This script works for the dialog that has close button but does not work for the other dialog box that has Don't Send button. Can you please see where i went wrong?

#include <File.au3>
AutoItSetOption("WinTitleMatchMode", "2") ; set the select mode to select using substring

If $CmdLine[0] < 1 Then; Arguments are not enough
    MsgBox(0, "Error", "Supply all the arguments, Log File Name is Mandatory")
    Exit
EndIf

_FileCreate($CmdLine[1])

WinWait("Internet Explorer","Internet Explorer ha")
If Not WinActive("Internet Explorer","Internet Explorer ha") Then 
    WinActivate("Internet Explorer","Internet Explorer ha")
    $file = FileOpen($CmdLine[1], 2)
    FileWrite($file, "ERROR: Internet Explorer Crashed.")

    If ControlClick("Internet Explorer","Internet Explorer ha","&Close")=0 Then
    ControlClick("Internet Explorer","Internet Explorer ha","&Don't Send")
    EndIf
    FileClose($file)
EndIf

If WinExists("Internet Explorer","Internet Explorer ha") Then
    $file = FileOpen($CmdLine[1], 2)
    FileWrite($file, "ERROR: Internet Explorer Crashed.")
    FileClose($file)
    WinClose("Internet Explorer","Internet Explorer ha")
EndIf
Link to comment
Share on other sites

It's this portion of your code:

If Not WinActive("Internet Explorer","Internet Explorer ha")
Then WinActivate("Internet Explorer","Internet Explorer ha")

Remove it and it works fine. Here is my example using a clone of the IE crashed message box.

Now keep in mind that this ugly hack is just a monster that I had to create because I couldn't get IE to crash -- GASP!

#include <File.au3>

AutoItSetOption("WinTitleMatchMode", 2) ; set the select mode to select using substring
AutoItSetOption("GUIOnEventMode", 1)

Global $FILE = @DesktopDir & "\file.txt"
_FileCreate($FILE)

Global Const $IE_Title = "Internet Explorer"
Global Const $IE_Text = "Internet Explorer ha"

; clone the IE message box
GUICreate($IE_Title)
GUISetOnEvent(-3, "term")

GUICtrlCreateLabel("Internet Explorer has crashed", 10, 10)

; be sure to comment this out if you want to simulate the messagebox with a DontSend button
Global $buttonClose = GUICtrlCreateButton("&Close", 50, 50)
GUICtrlSetOnEvent($buttonClose, "_Close")

; be sure to comment this out if you want to simulate the messagebox with a CLose button
;~ Global $buttonDontSend = GUICtrlCreateButton("&Don't Send", 100, 50)
;~ GUICtrlSetOnEvent($buttonDontSend, "_DontSend")

GUISetState()

WinWait($IE_Title, $IE_Text)

FileOpen($FILE, 2)

FileWrite($FILE, "ERROR: Internet Explorer Crashed.")

If Not ControlClick($IE_Title, $IE_Text, "&Close") Then
    ControlClick($IE_Title, $IE_Text, "&Don't Send")
EndIf

FileClose(1)

Func _Close()
    ConsoleWrite("Close" & @LF)
EndFunc ;==>_Close

Func _DontSend()
    ConsoleWrite("DontSend" & @LF)
EndFunc ;==>_DontSend

Func term()
    Exit
EndFunc ;==>term
Edited by jaberwocky6669
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...