Skip to main content

Jan 22, 2009 - 2 minute read - Evil Tester Selenium

Get rid of those pesky IE dialogs with AutoIt

Over the years I have used and reused a variant of a single AutoIt script. The script basically polls windows for a dialog that matches a certain pattern and then performs some action.

I most recently used this to get rid of the IE dialog that pops up using Selenium with IEHTA asking if you want the web page to close the window.

So this script provides an easier way of getting rid of the dialog than sitting there clicking it (or shooting it) - after all, you automate so you don’t have to sit there.

The scripts as written get rid of:

  • the IE 6 dialog “The Web page you are viewing is trying to close the window.
  • the IE7 dialog “The webpage you are viewing is trying to close the window.”
  • and a FireFox 2 dialog for slow scripts

I mentioned this script in a previous post - but I forgot to upload it. Hence this post.

I have included the compiled .exe version as well but feel free to download AutoIt and compile it for yourself - then you can learn a little more about AutoIt and the scripts.

Variations of this script I have used in the past include:

  • polling for IE proxy password boxes and filling in my details
  • polling for server logins on running machines to allow remote tests to run
  • getting rid of various dialogs that appear when I login to my machine

[download] - get AutoIt too

Should you not want to download it then I have pasted the raw script below:

Global $foundOne
Global $sleepVal
$sleepVal = 1000

While 1

process_window_if_it_exists("Windows Internet Explorer", 
    "The webpage you are viewing is trying to close the window.","Button1")   ;IE7
process_window_if_it_exists("Microsoft Internet Explorer", 
     "The Web page you are viewing is trying to close the window.","Button1") ;IE6
process_window_if_it_exists("Warning: Unresponsive script", 
     "A script on this page may be busy, or it may have stopped responding.", 
	 "Continue") ;FireFox 2

if $foundOne < 10 Then
  $sleepVal = 100
  $foundOne = $foundOne + 1
  $foundOne = 11
  $sleepVal = 5000 ;5 seconds


func process_window_if_it_exists($winTitle, $checkMsg, $buttonName)
if WinExists($winTitle,"") Then
  if StringLeft(ControlGetText($winTitle,"","Static2"),
               StringLen($checkMsg)) = $checkMsg  then
  $foundOne = 1

- in Evil Tester Selenium

You will need a Github account to comment. Or you can contact me with your comment.

I reserve the right to delete spam comments e.g. if your comment adds no value and its purpose is simply to create a backlink to another site offering training, or courses, or etc.