autoit imagesearch 透明度参数不起作用

autoit imagesearch transparency parameter not working

我需要在屏幕上使用搜索透明图像。我尝试了一些图书馆。但这些并不如我所愿。

帮帮我。我如何完成这里输入代码

#include "ImageSearch2015.au3"
#include <Date.au3>

Global $x = 0
Global $y = 0

HotKeySet("{UP}","hey")
HotKeySet("{DOWN}","heyo")

Func hey()
    $balikcisaniye = _Date_Time_GetTickCount()
    $array = _ImageSearchArea("bul.bmp", 1, 0, 0, @DesktopWidth/2, @DesktopHeight/2, $x, $y, 2,0x000000)
    if($array = True) Then 
        $balikcisaniye1 = _Date_Time_GetTickCount()
        MouseMove($x,$y)
        MsgBox(1,"","Found." & $x & "-" & $y & " / " & $balikcisaniye1-$balikcisaniye)
    Else
        MsgBox(1,"","Not Found.")
    EndIf
EndFunc

Func heyo()
    exit
EndFunc

while 1
WEnd

此脚本使用的库:(KutayAltinoklu)

https://www.autoitscript.com/forum/topic/148005-imagesearch-usage-explanation/page/4/

错误!

好的,我测试了一下,发现UDF有bug。它不能像现在这样工作。

  • 打开 ImageSearch2015.au3(或任何您将其重命名的名称)
  • 找到以 if $transparency <> 0 开头的行(未修改的第 137 行 ImageSearch2015.au3
  • 将该条件替换为 if IsString($transparency) 它现在应该如下所述工作

用法

UDF 似乎使用了来自 AutoHotkey 的 ImageSearch DLL。 This is its documentation.

如果这是真的,那么链接的 UDF 的文档是 wrong/incomplete。

AHK 的文档是这样说的:

This option makes it easier to find a match by specifying one color within the image that will match any color on the screen. It is most commonly used to find PNG, GIF, and TIF files that have some transparent areas (however, icons do not need this option because their transparency is automatically supported). For GIF files, TransWhite might be most likely to work. For PNG and TIF files, TransBlack might be best. Otherwise, specify some other color name or RGB value

BMP 不支持内置透明颜色,但应该没问题 - 您只需将任何一种颜色指定为透明 - 该颜色将被忽略

我已经阅读了文档和 UDF 源代码,这似乎是应该作为透明度参数传递的内容:

任一:

  • string "TransBlack" 如果透明色为黑色 (000000) 或
  • string "TransWhite" 如果透明色为白色 (FFFFFF) 或
  • string "Trans224466" otherwise - 其中 224466 是指定为透明的颜色的十六进制字符串
    • 也就是说,如果您的颜色存储为整数,则需要执行类似 "Trans" & hex(0x998877, 6) 的操作,其中 0x998877 是颜色

例子

例如,如果您的图片 bul.bmp 有一张根据背景颜色 #808080(50% 灰色)绘制的图片。所以如果你这样调用函数:

$array = _ImageSearchArea("bul.bmp", 1, 0, 0, @DesktopWidth/2, @DesktopHeight/2, $x, $y, 2, "Trans808080")

...bul.bmp 的所有背景(50% 灰色)像素应匹配屏幕上的任何颜色,即 - 这些像素将被忽略。

也就是说,如果 bul.bmp 只是一个没有其他颜色的纯色 50% 灰色矩形,函数将始终匹配。如果它在任何位置有一个非灰色像素,如果屏幕包含该颜色的像素等,它将匹配。