Jump to content
Sign in to follow this  

_ImageSearchArea returns ~38k results...

Recommended Posts


I'm hoping someone can help me with this issue that I'm having.

I am trying to automate performance testing of an application for work, but in certain situations I am seeing _ImageSearchArea return ridiculous numbers of results while other times it works perfectly fine.

System: Remote Session of Windows Server 2008 R2 Enterprise

$winDims = WinGetPos('Open Database')
  Switch $selectedAOR
   Case $selectedAOR = 'system'
    $picFile = @TempDir & '\Performance_Test\ormap_system.bmp'
    $imageCoords = _ImageSearchArea($picFile, $winDims[0], $winDims[1], $winDims[0] + $winDims[2], $winDims[1] + $winDims[3])
    If Not IsArray($imageCoords) Then
     $errorMessage = 'Image not found on screen: ' & $picFile
    MouseClick("left", $imageCoords[0][0], $imageCoords[0][1])

*Just a subset of code to show how I'm using _ImageSearchArea

This is the picture that I'm searching for


And this is the window that I'm searching in


And this is the number of results returned by _ImageSearchArea


Share this post

Link to post
Share on other sites

Image search doesn't return a value like normal autoit functions. You need to give the image search function variables to store the x and y coords. You have an if statment that will give an error msg if the variable is NOT an array and then you r trying to use that say variable as an array which is incorrect. Once I get home i can post my image search function.

Share this post

Link to post
Share on other sites

Thanks for the reply,

_ImageSearchArea returns an array with x,y coordinates so I don't see anything wrong with what I'm currently doing???

Func _ImageSearchArea($findImage,$x1,$y1,$right,$bottom, $tolerance = 0, $HBMP=0)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
If IsString($findImage) Then
  $result = DllCall($ImageSearchDLL,"str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str","*TransBlack "&$findImage,"ptr",$HBMP)
;~  _ArrayDisplay($result,"")
;~  ConsoleWrite($result & @CRLF)
  $result = DllCall($ImageSearchDLL,"str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr","*TransBlack "&$findImage,"ptr",$HBMP)
;~  $result = DllCall($ImageSearchDLL,"str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
;~  ConsoleWrite(@error & @CRLF)
;~  Return $result
; If error exit
    if Not IsArray($result) Or $result[0]="0" then return 0
$array = StringSplit($result[0],"#",2)
If UBound($array) < 2 Then
;~   _ArrayDisplay($array,"UB $result[0] < 2 ??")
  Return 0
Dim $retArray[UBound($array)-1][2]
For $i = 0 To UBound($array)
  $xyarr = StringSplit($array[$i],"|",2)
  If @error Then ExitLoop
  $retArray[$i][0] = $xyarr[0]
  $retArray[$i][1] = $xyarr[1]
;~  _ArrayDisplay($retArray,"")
   return $retArray

**Hmmm am I using an old version of imagesearch???**

It works perfectly except for this specific image when running on a remote session.

Edited by zpanderson

Share this post

Link to post
Share on other sites

Alrighty, well I downloaded an updated version of ImageSearch from and reworked my code...

It appears to be working better now; not sure where I got that original version of imagesearch that I was using o.O

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.