Skip to content

Match Color Point ​

Check if all specified color points exist in the specified region of device screenshot, supports similarity threshold settings. Returns true if all colors are found, otherwise throws an error indicating which colors were not found.

Interface Description ​

Interface Type ​

matchColorPoint

Parameters ​

ParameterTypeRequiredDescription
deviceIdstringYesDevice ID
colorsarrayYesColor array, format: `[color
rectarrayNoSearch area [x1, y1, x2, y2], default full screen

Return Value ​

On Success:

javascript
true  // All colors found in specified region

On Failure:

javascript
null

Feature Description ​

Color Format ​

Each element in the color array has the format: "color|threshold"

  • Color: 6-digit hexadecimal color value, e.g., "FFFFFF"
  • Threshold: Similarity threshold, range 0-1, similarity = round((1 - threshold) * 255), same for all three channels

Search Area ​

The rect parameter defines the search area:

  • Format: [x1, y1, x2, y2]

Use Cases ​

Case 1: Verify UI State ​

Check if system modal exists:

javascript
const _hasSysModal = await apiInvoke('matchColorPoint', {
    deviceId: 'P72578581E07',
    colors: ["FFFFFF|0.8", "222222|0.9", "1074EC|0.9"],
    rect: [200, 300, 400, 350]
});

💡 Tip

  • Unlike findMultiColor, matchColorPoint does not return specific coordinates, only verifies if colors exist
  • Suitable for UI state verification, conditional checks, and similar scenarios

Cooperation: try.catch@foxmail.com