i trying detect image in window. window bluestacks program. using imagesearch algorthim. problem fails.
$result = dllcall("imagesearchdll.dll","str","imagesearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findimage) as know dllcall should return array if successful. thing is, returns 1 indicate failure in dllcall. have tried x86 , x64 versions of algorighm. how call _imagesearcharea
_captureregion() _imagesearcharea($gameimage, 0,0,0,500,500, $x, $y, 0) i have win 7 x64 op system . x64 autoit installed
the window (bluestacks) resolution 577 690
this imagesearch using
#include-once ; ------------------------------------------------------------------------------ ; ; autoit version: 3.0 ; language: english ; description: functions assist image search ; require imagesearchdll.dll loadable ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; description: find position of image on desktop ; syntax: _imagesearcharea, _imagesearch ; parameter(s): ; $findimage - image locate on desktop ; $tolerance - 0 no tolerance (0-255). needed when colors of ; image differ desktop. e.g gif ; $resultposition - set returned x,y location of image is. ; 1 centre of image, 0 top left of image ; $x $y - return x , y location of image ; ; return value(s): on success - returns 1 ; on failure - returns 0 ; ; note: use _imagesearch search entire desktop, _imagesearcharea specify ; desktop region search ; ;=============================================================================== 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) ;msgbox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 $findimage = "*" & $tolerance & " " & $findimage $result = dllcall("imagesearchdll.dll","str","imagesearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findimage) ; if error exit if $result[0]="0" return 0 ; otherwise x,y location of match , size of image ; compute centre of search $array = stringsplit($result[0],"|") $x=int(number($array[2])) $y=int(number($array[3])) if $resultposition=1 $x=$x + int(number($array[4])/2) $y=$y + int(number($array[5])/2) endif return 1 endfunc ;=============================================================================== ; ; description: wait specified number of seconds image appear ; ; syntax: _waitforimagesearch, _waitforimagessearch ; parameter(s): ; $waitsecs - seconds try , find image ; $findimage - image locate on desktop ; $tolerance - 0 no tolerance (0-255). needed when colors of ; image differ desktop. e.g gif ; $resultposition - set returned x,y location of image is. ; 1 centre of image, 0 top left of image ; $x $y - return x , y location of image ; ; return value(s): on success - returns 1 ; on failure - returns 0 ; ; ;=============================================================================== func _waitforimagesearch($findimage,$waitsecs,$resultposition,byref $x, byref $y,$tolerance) $waitsecs = $waitsecs * 1000 $starttime=timerinit() while timerdiff($starttime) < $waitsecs sleep(100) $result=_imagesearch($findimage,$resultposition,$x, $y,$tolerance) if $result > 0 return 1 endif wend return 0 endfunc ;=============================================================================== ; ; description: wait specified number of seconds of set of ; images appear ; ; syntax: _waitforimagessearch ; parameter(s): ; $waitsecs - seconds try , find image ; $findimage - array of images locate on desktop ; - array[0] set number of images loop through ; array[1] first image ; $tolerance - 0 no tolerance (0-255). needed when colors of ; image differ desktop. e.g gif ; $resultposition - set returned x,y location of image is. ; 1 centre of image, 0 top left of image ; $x $y - return x , y location of image ; ; return value(s): on success - returns index of successful find ; on failure - returns 0 ; ; ;=============================================================================== func _waitforimagessearch($findimage,$waitsecs,$resultposition,byref $x, byref $y,$tolerance) $waitsecs = $waitsecs * 1000 $starttime=timerinit() while timerdiff($starttime) < $waitsecs $i = 1 $findimage[0] sleep(100) $result=_imagesearch($findimage[$i],$resultposition,$x, $y,$tolerance) if $result > 0 return $i endif next wend return 0 endfunc $gameimage , image want compare , have prepared no worries there.
please detect problem.
$findimage string variable, dll call should this.
$result = dllcall("imagesearchdll.dll","str","imagesearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findimage)
Comments
Post a Comment