Table of Contents

ImageSearch with AutoIt

Overview

I needed the ability for AutoIt to find something on the screen matching a reference image. Unfortunately, this is not an available built-in feature. There are functions available for checking individual pixels, but no way to match groups of pixels or images.

I found a solution in this thread. The key is the AutoHotkey ImageSearch function. Someone extracted the ImageSearch code from AutoHotkey, packed it up in to convenient DLLs, and put together a UDF library that acts as a wrapper.

I took the UDF library and made the following improvements to it:

Example

; Include the ImageSearch library
#include ".\ImageSearch\ImageSearch.au3"
; This will be the target image file to search for
Local $target = "DemoTarget.png"
; Declare an init a variable to hold the search result
Local $result = False
; Find the image across the entire desktop
$result = _ImageSearch($target, 1)
; If found, move the mouse to it
If IsArray($result) Then MouseMove($result[0], $result[1])

Download

I've put it up on GitHub.