Automating Internet Explorer with Auto It. (Windows Tasks Automation software)

Summary:

This article presents the automation of browsing using Internet Explorer and a commercial email provider: Yahoo.

Auto It was used to:

1. automatically start Internet Explorer,

2. login to Yahoo (if the user was not using the option auto-login) via sending key strokes,

3. and then to open the Inbox using the mouse.

Introduction:

Auto It is a free-ware application: http://www.autoitscript.com/autoit3/downloads.shtml

It has a set of functionality that can be readily deployed, i.e., a utility that provides the windows’ names, mouse coordinates, etc.  The caption is shown below:

AutoItWindowDetection

To start a program we issue the command: Run(“C:\Program Files\Internet Explorer\iexplore.exe”)

Since automation is accomplished using the windows’ names, the window name is used:

WinWaitActive(“Google – Windows Internet Explorer”)

The script is shown at the end.

Brief description of the script:

Two functions have been defined: login() and go2inbox().

The login function waits until the Yahoo! Mail window is active and then sends keystrokes (user id, tab, password, tab, enter) in order to access the email provider.

The go2inbox also waits until the Yahoo! Mail window is active and then it controls the mouse and directs it to the coordinates specified with:

MouseClick(“left”,45,505,1)   –Notice that the IExplore window must be maximized.

Notes:

Handling the active windows takes the following into consideration:

1. If some windows have similar title but not exactly the same, and still they need to be considered as the same (Yahoo! Mail is common for login and for inbox.  But the exact names differ.  Auto It provides a way to use a substring of the name)

2. If tabbing doesn’t work in a certain window, mouse click is the alternative.

3. When browsing some window the info doesn’t appear immediately.  It is advisable to use the sleep function with a time of 5 seconds to ensure the needed control is available.

Script:

; AutoIt Version: 3.0
; Language:       English
; Platform:       WinXP
; Author:         Omar Flores (omar.flores.i.t@gmail.com), modified from an example by Jonathan Bennett (jon@hiddensoft.com)
; Script Function:
;   Opens IExplorer, types mail.yahoo.com, logs in, checks the inbox.
;
Opt(“WinTitleMatchMode”, 2)  ;match substring of window

; Prompt the user to run the script – use a Yes/No prompt
$answer = MsgBox(4, “AutoIt Example (English Only)”, “This script will run IExplorer, browse to YahooMail, login and check the Inbox.  Run?”)

; Check the user’s answer to the prompt (see the help file for MsgBox ;return values),If “No” was clicked (7) then exit the script
If $answer = 7 Then
MsgBox(0, “AutoIt”, “OK.  Bye!”)
Exit
EndIf

; Run IExplorer
Run(“C:\Program Files\Internet Explorer\iexplore.exe”)

; Wait for the IExplorer to become active – it is titled “Google – Windows Internet Explorer” on English systems
WinWaitActive(“Google – Windows Internet Explorer”)
Sleep(1000)
send(“{tab 11}”)  ;to be in the url location

Sleep(2000)
Send(“mail.yahoo.com{Enter}”)   ;type the yahoo mail url

login()   ;if the yahoo user has signed out, then login will sign in.
copymail function
go2inbox()

Func login()
WinWaitActive(“Yahoo! Mail”)
if WinExists(“Yahoo! Mail: The best web-based email! – Windows Internet Explorer”) then
Send(“florespino”)
Sleep(1500)
send(“{TAB}password”)
sleep(2500)
send(“{TAB 2}{Enter}”)
endif

EndFunc

Func go2inbox()
WinWaitActive(“Yahoo! Mail”)  ;WinWaitActive(“Yahoo! Mail”,3) didn’t work, I removed the 3.
if WinExists(“Yahoo! Mail”) Then
sleep(5000)
MouseClick(“left”,45,505,1)  ;ONLY worked with full size window!  Otherwise the window always moved.
EndIf
EndFunc

Omar Flores

System Integration Test Engineer

Omar.flores.i.t@gmail.com

Advertisements

4 Responses to “Automating Internet Explorer with Auto It. (Windows Tasks Automation software)”

  1. bradley Says:

    hay how would i sign in to my myspace with autoit

  2. hoohead Says:

    “MouseClick(“left”,45,505,1) ;ONLY worked with full size window! ”

    and it only works with the same Screenresolution 😉

    • florespino Says:

      Thanks for the feedback. Maybe you can come up with a way to make it independent from screen resolution and full size window 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: