找回密码
 加入
搜索
查看: 3220|回复: 7

[图形处理] 新手对imaginesearch的疑问

  [复制链接]
发表于 2010-12-28 22:44:16 | 显示全部楼层 |阅读模式
本帖最后由 处女 于 2010-12-31 20:34 编辑

为什么用picpick软件剪切下来的bmp格式图片能收索到而上QQ时用ALT+CTRL+A剪切下来的bmp格式的图片却收索不到呢?????能给我略微讲讲吗?或者给我一点启示呀?
发表于 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] = [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
但是这段代码研究2小时之久,有几处实在难以琢磨!尤其是您所说的透明度$trans = "transblack", $variation = 60, $runs = 1, $behavior = 1)
这些参数都代表什么呢? 还有Dim $aCoords[$runs] = [99999]; 为什么要这样呢?        我实在是菜,真的感觉知识越学越多。。。。。。。。。。。。。。。。。。。。。
发表于 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] = "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[0], "|")

        $x = Int(Number($array[2]))
        $y = Int(Number($array[3]))
        If $resultPosition = 1 Then
                $x = $x + Int(Number($array[4]) / 2)
                $y = $y + Int(Number($array[5]) / 2)
        EndIf
        Return 1
EndFunc   ;==>_ImageSearchArea
 楼主| 发表于 2010-12-30 19:46:08 | 显示全部楼层
哦,,,您给的代码让我明了了许多,至于透明度那种深度的问题我想我还是先多学学基础的东西后再来研究,否则看什么都是一头雾水。最后一个问题:$findImage = "*" & $tolerance & " " & $findImage这段代码怎么解释呢?
谢谢您还一直关注我的问题。。感谢。。。
发表于 2010-12-31 12:09:02 | 显示全部楼层
其实这就是ahk的语法  在文件名这个参数里  前面是一些参数 这里是加上模糊度(容错度)

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

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

评分

参与人数 1金钱 +10 收起 理由
处女 + 10

查看全部评分

 楼主| 发表于 2010-12-31 20:31:33 | 显示全部楼层
哦,明白了,"*" & $tolerance & " " & $findImage我说怎么$tolerance和$findimage之间要有个空格呢,谢谢了管理员。。。。。。。元旦快乐~!!!!
 楼主| 发表于 2010-12-31 20:45:19 | 显示全部楼层
怎么把帖子改成以解决问题区啊?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 05:49 , Processed in 0.085568 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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