Func _test()
$result = _imagesearch("Source", 0, 0,600,800, "search", 40, 3, 1)
MsgBox(0,"",$result)
EndFunc
Func _Imagesearch($file, $x1, $y1 , $x2, $y2, $trans = "transblack", $variation = 60, $runs = 1, $behavior = 1)
If $behavior > 3 Or $behavior < 0 Then $behavior = 1
If $runs < 1 Or $behavior = 0 Then $runs = 1
Dim $aCoords[$runs] = [99999]; just some number to make the _ArrayMax <-> _ArrayMin comparison work on it's first run
$findImage = '*' & $trans & ' ' & '*' & $variation & ' ' & $file & ".bmp"
$dll = DllOpen("imagesearchdll.dll")
While 1
$result = DllCall($dll, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $x2, "int", $y2, "str", $findImage)
If $result[0] = "0" Then
_ArrayPush($aCoords, 0, 1)
Else
_ArrayPush($aCoords, 1, 1)
If $behavior = 1 Then ExitLoop
EndIf
If _ArrayMax($aCoords) == _ArrayMin($aCoords) Then ExitLoop
Sleep(40)
WEnd
DllClose($dll)
If $aCoords[0] = 1 Then
$array = StringSplit($result[0], "|")
Dim $aCoords[5] = [4, Int(Number($array[2])), Int(Number($array[3])), Int(Number($array[2])) + Int(Number($array[4]) / 2), Int(Number($array[3])) + Int(Number($array[5]) / 2)]
Return ($aCoords)
Else
Return (0)
EndIf
EndFunc
|