Skip to content

Find Color

Find specified colors and their offset colors in device screenshot, supports multi-point color recognition and tolerance matching.

Interface Description

Interface Type

findColor

Parameters

ParameterTypeRequiredDescription
deviceIdstringYesDevice ID
colorstringYesMain color (hex format, e.g., "FFFFFF")
offsetColorstringYesOffset color group
rectarrayNoSearch area [x1, y1, x2, y2], default full screen
thresholdnumberNoColor tolerance (0-1), default 0.9
multiplebooleanNoWhether to find all matching locations, default false
directionnumberNoSearch direction 0-3, default 0

Return Value

Single Match (multiple = false):

javascript
{
    x: 100,  // X coordinate of match point
    y: 200   // Y coordinate of match point
}

Multiple Matches (multiple = true):

javascript
[
    { x: 100, y: 200 },
    { x: 150, y: 250 },
    { x: 200, y: 300 }
]

Basic Usage

javascript
// Find single color point
const result = await apiInvoke('findColor', {
    deviceId: 'P72578581E07',
    color: '000000',              // Main color
    offsetColor: '10|0|f6f6f6'    // Offset color
});

if (result) {
    console.log(`Found color point at (${result.x}, ${result.y})`);
}

Feature Description

Color Format

Colors use hexadecimal format:

  • 888888 - Gray

Offset Color Format

Offset colors for multi-point color matching, format: "x|y|color,x|y|color,..."

Search Direction

directionDescription
0Left to right, top to bottom (default)
1Right to left, top to bottom
2Left to right, bottom to top
3Right to left, bottom to top

Color Tolerance

threshold parameter controls color matching accuracy:

  • 1.0 - Perfect match, no deviation allowed
  • 0.9 - Allow about 10% color deviation (recommended)
  • 0.8 - Allow about 20% color deviation
  • 0.7 - Allow about 30% color deviation

💡 Tip

Multi-point color matching is more accurate than single point. It's recommended to use 3-5 feature points to identify UI elements, effectively avoiding false matches. Offset color coordinates are relative to the main color point, pay attention to relative position when setting.

Cooperation: try.catch@foxmail.com