Data Driven AutoIt Scripts

I’ve recently been playing around with AutoIt in an effort to steer clear of QTP and the like. AutoIt is a simple but effective way in which to automate pretty much any Windows GUI application. To that end I needed a simple data driven framework to include in the script. AutoIt comes with some handy Excel user defined functions which allow you to do the same.

For example, the following spreadsheet:
autoit spreadsheet example

Can be read into an array and looped through as follows:

#include <excel.au3>
#include <array.au3>
 
$file = @ScriptDir & "\excel.xls"
$oExcel = _ExcelBookOpen($file, 0) ; open excel in the background
 
$aArray = _ExcelReadSheetToArray($oExcel, 2) ; ignoring header row
_ArrayDisplay($aArray, "Array using Default Parameters")
 
For $i = 1 to UBound($aArray)-1
	$name 	 = $aArray[$i][1]
	$surname = $aArray[$i][2]
 
	; do application stuff
	MsgBox(0,'debug', $name &' '& $surname )

	; write result to the book
	_ExcelWriteCell($oExcel, "PASS", $i+1, 5)
 
Next
 
_ExcelBookClose($oExcel) ; close excel

Pretty simple stuff!

Social tagging:

One Response to Data Driven AutoIt Scripts

  1. I’m coping with QTP but am trying to get away from using the data table and parameters and want to use autoit to prompt (within a gui) for input parameters and then output to an excel spreadsheet which I read for every run. Can you tell me if there are any examples of autoit creating a gui prompting text box entry and writing to excel spreadsheet? Tried google with no luck
    Joe