代码之家  ›  专栏  ›  技术社区  ›  ulou Matt Wonlaw

获取所有像素位置

  •  0
  • ulou Matt Wonlaw  · 技术社区  · 8 年前

    我正在使用 PixelSearch 函数,我知道如何找到1 像素 这符合我的标准,但问题是我想找到所有 像素 具体的 颜色 并将其添加到 大堆 ,所以我可以使用它 兰德 一个并点击它。

    源代码:

    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
    

    我想找到 所有像素 不是一个“第一”。我该怎么做?我遗漏了什么吗?

    1 回复  |  直到 8 年前
        1
  •  3
  •   Daniel user3757731    8 年前

    不能 使用 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 基于相同的原理。