PixelSearch

화면 구역을 검색해 지정된 색을 가진 픽셀을 찾습니다.

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID , Variation, Mode

매개변수

OutputVarX, OutputVarY

The names of the output variables in which to store the X and Y coordinates of the first pixel that matches ColorID (if no match is found, the variables are made blank). 좌표는 활성 창에 상대적입니다. 단, CoordMode가 사용되어 좌표가 변경된 경우는 제외합니다.

이 매개변수가 비어 있는 경우가 있습니다. 그러면 ErrorLevel (아래 참조)를 사용하여 일치가 발견되었는지 알아낼 수 있습니다.

X1, Y1

The X and Y coordinates of the starting corner of the rectangle to search, which can be expressions. 좌표는 활성 창에 상대적입니다. 단, CoordMode가 사용되어 좌표가 변경된 경우는 제외합니다.

X2, Y2

The X and Y coordinates of the ending corner of the rectangle to search, which can be expressions. 좌표는 활성 창에 상대적입니다. 단, CoordMode가 사용되어 좌표가 변경된 경우는 제외합니다.

ColorID

검색에 사용할 청-녹-적(Blue-Green-Red (BGR)) 형식의 십육진 또는 십진 컬러 ID. 표현식 가능. Color ID는 Window Spy를 사용하여 또는 PixelGetColor를 통하여 알아낼 수 있습니다 (트레이 메뉴로 접근 가능). 예를 들어: 0x9d6346.

Variation

0과 255 (포함) 사이의 값. 컬러의 적녹청 채도에 대하여 방향에 관계없이 몇 개의 쉐이드 변형을 허용할지 나타냅니다. (표현식 가능). For example, if 2 is specified and ColorID is 0x444444, any color from 0x424242 to 0x464646 will be considered a match. 이 매개변수는 구하는 컬러가 언제나 정확하게 같은 쉐이드가 아닐 경우 유용합니다. 255 쉐이드 변형을 지정하면, 모든 색이 부합합니다. 기본 값은 0 쉐이드입니다.

Mode

이 매개변수는 단어 Fast, RGB를 담거나 또는 둘 담을 수 있습니다 (둘 다 존재하면, 스페이스로 둘사이를 가르십시오; 즉, Fast RGB).

Fast: 빠른 검색 방법을 사용합니다. 대부분의 경우 검색에 사용된 CPU 시간의 양을 극적으로 줄여줍니다. 8-비트 (256-색) 컬러 깊이를 지원하지만, 빠른 모드는 24-비트 또는 32-비트 컬러에서 훨씬 더 빠릅니다. 화면의 컬러 깊이가 16-비트 이하라면, Variation 매개변수는 빠른 모드에서 느린 모드와 약간 다르게 행동할 수도 있습니다. 마지막으로, 빠른 모드는 화면을 컬럼 단위가 아니라 줄 단위로 검색합니다. 그러므로, 부합하는 픽셀이 많은 경우 느린 모드에서 발견되는 픽셀과 다른 픽셀을 발견할 수도 있습니다.

Note: The default Slow mode is unusable on most modern systems due to an incompatibility with desktop composition, which causes it to be orders of magnitude slower.

RGB: ColorID는 BGR이 아니라 RGB 값으로 번역됩니다. 다른 말로, 적과 청 구성요소가 서로 바뀝니다.

에러 처리

[v1.1.04+]: 이 명령어는 검색하는 동안 문제가 있다면 예외를 던질 수 있습니다. 더 자세한 정보는 실행시간 에러를 참조하십시오.

ErrorLevel은 지정된 구역에서 컬러를 발견하였으면 0이 설정되고, 발견하지 못했으면 1이 설정됩니다. 아니면 문제가 있어서 검색을 수행하지 못했으면 2가 설정됩니다.

논평

검색될 구역은 반드시 보여야 합니다; 다른 말로, 다른 창 뒤에 가려진 창의 구역은 검색할 수 없습니다. 대조적으로, 마우스 아래의 커서는 보통 탐지할 수 있습니다. 이에 대한 예외는 게임 커서입니다. 대부분의 경우 게임 커서는 자신의 아래에 있는 픽셀들을 감춥니다.

The search order depends on the order of the parameters. 다른 말로, X1X2보다 더 크면, 검색은 X1컬럼에서 시작하여, 오른쪽에서 왼쪽으로 수행됩니다. Similarly, if Y1 is greater than Y2, the search will be conducted from bottom to top. However, prior to [v1.1.32], the fast mode required X1 and Y1 to be the top-left corner.

Fast mode: The search starts at the coordinates specified by X1 and Y1 and checks all pixels in the row from X1 to X2 for a match. If no match is found there, the search continues toward Y2, row by row, until it finds a matching pixel.

Slow mode: The search starts at the coordinates specified by X1 and Y1 and checks all pixels in the column from Y1 to Y2 for a match. If no match is found there, the search continues toward X2, column by column, until it finds a matching pixel.

검색될 구역이 방대하고 검색이 높은 빈도록 반복되면, CPU 시간을 많이 소비할 수 있습니다. 이를 경감하려면, 검색 구역의 크기를 최소한으로 유지하십시오.

PixelGetColor, ImageSearch, CoordMode, MouseGetPos

예제

Searches a region of the active window for a pixel and stores in Px and Py the X and Y coordinates of the first pixel that matches the specified color with 3 shades of variation.

PixelSearch, Px, Py, 200, 200, 300, 300, 0x9d6346, 3, Fast
if ErrorLevel
    MsgBox, 해당 컬러를 지정된 구역에서 발견하지 못했습니다.
else
    MsgBox, 3 쉐이드의 변형 안에서 컬러가 X%Px% Y%Py%에서 발견되었습니다.