找回密码
 加入
搜索
查看: 2787|回复: 2

[图形处理] 图片查找imagesearch这个东西好奇怪

[复制链接]
发表于 2010-12-21 00:06:04 | 显示全部楼层 |阅读模式
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
 楼主| 发表于 2010-12-21 00:12:14 | 显示全部楼层
可以帮我逐一的解释一下代码意思吗,
最好可以做一个例子。我看了许久也没能看出其中的奥秘,。。。。。上段的代码大概的意思我懂,就是很多细节看不明白,网上很难查的到,尤其对我这个没有基础的菜鸟来说更加困难,查都不知道从哪下手,版主,会员,和各路的无名高手能帮帮我吗
 楼主| 发表于 2010-12-21 23:52:03 | 显示全部楼层
第3行里的SOURCE,和 SEARCH.各指的是什么呢? 还有为什么一运行就出错在第25行,所没有定义数组。。。。。。??帮个忙啊,我有很急用啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-4 10:12 , Processed in 0.078175 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表