获取所有像素位置

Get all pixels location

我使用 PixelSearch 函数,我知道如何找到符合我的条件的 1 像素 ,但问题是我想找到所有 pixels of specific color 并将其添加到 array,所以我可以将它用于 rand 一个并点击它。

源代码:

Local $aCoord = PixelSearch(0, 0, $clientSize[0], $clientSize[1], 0x09126C, 10, 1, $hWnd)
If Not @error Then
    ; add to array and search next
Else
    GUICtrlSetData($someLabel, "Not Found")
EndIf

我想找到 所有像素,而不是 "the first"。我怎样才能做到这一点?我错过了什么吗?

不能 使用 PixelSearch 完成,因为它会在找到匹配像素时停止执行。

可以通过在您所在的区域循环 PixelGetColor 来完成。类似于:

For $x = 0 To $clientSize[0] Step 1
   For $y = 0 To $clientSize[1] Step 1
      If PixelGetColor($x,$y,$hWnd) = 0x09126C Then
         ;Add $x and $y to Array using _ArrayAdd() (or whatever you prefer)
      EndIf
   Next
Next

这可能感觉比 PixelSearch 慢,因为它现在必须扫描整个区域,而不是在第一个匹配项停止,但它不应该如此,因为 PixelSearch同理