Skip to content

Tego Bot API Documentation v0.2.0


Tego Bot API Documentation / findInRegion

Function: findInRegion() ​

findInRegion(template, x, y, width, height, config?): Promise<MatchResult | null>

Defined in: botjs/src/image-match.ts:294

Find first match of template image in a specific screen region

Parameters ​

template ​

ImageResource

ImageResource to search for

x ​

number

X coordinate of search region

y ​

number

Y coordinate of search region

width ​

number

Width of search region

height ​

number

Height of search region

config? ​

MatchConfig

Optional matching configuration

Returns ​

Promise<MatchResult | null>

Promise resolving to MatchResult or null (coordinates are absolute screen coordinates)

Example ​

typescript
import { imageResource, findInRegion } from "@tego/botjs";

const button = await imageResource("./button.png");
// Search only in the left half of a 1920x1080 screen
const match = await findInRegion(button, 0, 0, 960, 1080, { confidence: 0.8 });

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

Released under the MIT License.