;Title: globals.au3 ; ;License: ; This script is distributed under the GNU General Public License 3. ; ;Author: ; Based in kangkeng UDF | http://www.autoitscript.com/forum/topic/65748-image-search-library/ | BlueDuck Team ; ;Description: ; Functions that assist with Image Search. Require that the ImageSearchDLL.dll be loadable #include-once ;Function: _ImageSearch ;ind the position of an image on the desktop ; ; Parameters: ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Returns: ; On Success - Returns 1 ; On Failure - Returns 0 Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance) Local $result Local $array if ($tolerance > 0) then $findImage = "*" & $tolerance & " " & $findImage EndIf $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage) ; If error exit If (IsArray($result) = 0) Then Return 0 Elseif $result[0] = "0" Then Return 0 Else ;get the x,y location $array = StringSplit($result[0],"|") $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif Return 1 EndIf EndFunc