Jump to content

_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
     ContinueCase
    EndIf
    MouseClick("left", $imageCoords[0][0], $imageCoords[0][1])
  EndSwitch

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

This is the picture that I'm searching for

ormap_system.bmp

And this is the window that I'm searching in

pic1.bmp

And this is the number of results returned by _ImageSearchArea

pic3.bmp

Link to comment
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.

Link to comment
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)
Else
  $result = DllCall($ImageSearchDLL,"str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr","*TransBlack "&$findImage,"ptr",$HBMP)
EndIf
;~  $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
EndIf
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]
next
;~  _ArrayDisplay($retArray,"")
   return $retArray
EndFunc

**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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...