PixelSearch
搜索提供像素颜色组成的像素矩形.
PixelSearch ( left, top, right, bottom, color [, shade-variation = 0 [, step = 1 [, hwnd]]] )
参数
left
|
矩形的左上角水平坐标(X).
|
top
|
矩形的左上角垂直坐标(Y).
|
right
|
矩形的右下角水平坐标(X).
|
bottom
|
矩形的右下角垂直坐标(Y).
|
color
|
搜索的颜色值(十进制或十六进制).
|
shade-variation
|
[可选] 0 到 255 之间的值, 用以指定红, 绿, 蓝的颜色深浅范围. 默认值为 0 (精确匹配).
|
step
|
[可选] 默认搜索每个象素, 此参数可指定跳过搜索的象素数量(提升执行速度).
例如, 数值 2 表示每隔一个象素搜索下一个. 默认值为 1. 不推荐使用大于 1 的步长值
|
hwnd
|
[可选] 目标窗口句柄. 默认为桌面窗口.
|
返回值
成功:
|
返回两个元素的坐标值数组. (Array[0] = x 坐标, Array[1] = y 坐标).
|
失败:
|
设置 @error 为 1, 表示未发现颜色.
|
备注
搜索方向的变化如下:
从左到右 - left < right
从右到左 - right < left
从上到下 - top < bottom
从下到上 - bottom < top
修改搜索方向, 对于特定搜索范围频繁出现的颜色, 可以优化搜索(次数).
记住, 典型的 1024 x 768 显示器有 786432 个像素,
虽然本函数进行了优化, 但减小搜索区域能帮助加快搜索速度.
函数示例
#include <MsgBoxConstants.au3>
; Find a pure red pixel in the range 0,0-20,300
Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
If Not @error Then
MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf
; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
If Not @error Then
MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf
----------------------------------------
该函数可以通过命令调用 exect
参见:
PixelChecksum, PixelGetColor, PixelCoordMode (Опция)
exect=$var_a=PixelSearch(0,0,20,300,0xFF0000)||IsArray($var_a)?_ViewValues($var_a):_ViewValues('颜色~~не~~найден') ;; 获得红色颜色a的数组像素坐标
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|