处女 发表于 2010-12-28 22:44:16

新手对imaginesearch的疑问

本帖最后由 处女 于 2010-12-31 20:34 编辑

为什么用picpick软件剪切下来的bmp格式图片能收索到而上QQ时用ALT+CTRL+A剪切下来的bmp格式的图片却收索不到呢?????能给我略微讲讲吗?或者给我一点启示呀?

sxd 发表于 2010-12-28 23:39:25

很久没用imagesearch了 你这问题也许和bmp的透明通道有关
其实imagesearch也是封装了ahk的imagesearch 可以用ahk的参数
试试找出透明颜色 然后 *Trans0xFFFFAA 加在图片路径的前面
具体参看ahk的帮助
http://www.autohotkey.com/docs/commands/ImageSearch.htm

处女 发表于 2010-12-29 21:32:52

首先万分感谢SXD给我出的主意!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] = ; 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" 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但是这段代码研究2小时之久,有几处实在难以琢磨!尤其是您所说的透明度$trans = "transblack", $variation = 60, $runs = 1, $behavior = 1)
这些参数都代表什么呢? 还有Dim $aCoords[$runs] = ; 为什么要这样呢?      我实在是菜,真的感觉知识越学越多。。。。。。。。。。。。。。。。。。。。。

sxd 发表于 2010-12-30 00:25:46

我不知道你的udf是哪里的 和我的不一样

Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance)
        Return _ImageSearchArea($findImage, $resultPosition, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, $tolerance)
EndFunc   ;==>_ImageSearch



Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
        ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
        If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
        $result = DllCall(DllOpen("imagesearchdll.dll"), "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)

        ; If error exit
        If $result = "0" Then Return 0

        ; Otherwise get the x,y location of the match and the size of the image to
        ; compute the centre of search
        $array = StringSplit($result, "|")

        $x = Int(Number($array))
        $y = Int(Number($array))
        If $resultPosition = 1 Then
                $x = $x + Int(Number($array) / 2)
                $y = $y + Int(Number($array) / 2)
        EndIf
        Return 1
EndFunc   ;==>_ImageSearchArea

处女 发表于 2010-12-30 19:46:08

哦,,,您给的代码让我明了了许多,至于透明度那种深度的问题我想我还是先多学学基础的东西后再来研究,否则看什么都是一头雾水。最后一个问题:$findImage = "*" & $tolerance & " " & $findImage这段代码怎么解释呢?
谢谢您还一直关注我的问题。。感谢。。。

sxd 发表于 2010-12-31 12:09:02

其实这就是ahk的语法在文件名这个参数里前面是一些参数 这里是加上模糊度(容错度)

所以文件名那个参数 不仅仅是可以放文件路径
例子

*2 *w100 *h-1 *Trans0xFFFFAA C:\MainLogo.bmp

处女 发表于 2010-12-31 20:31:33

哦,明白了,"*" & $tolerance & " " & $findImage我说怎么$tolerance和$findimage之间要有个空格呢,谢谢了管理员。。。。。。。元旦快乐~!!!!

处女 发表于 2010-12-31 20:45:19

怎么把帖子改成以解决问题区啊?
页: [1]
查看完整版本: 新手对imaginesearch的疑问