Skip to content

Tego Bot API Documentation v0.2.0


Tego Bot API Documentation / findAllInRegion

Function: findAllInRegion() ​

findAllInRegion(template, x, y, width, height, config?): Promise<MatchResult[]>

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

Find all matches 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[]>

Promise resolving to array of MatchResults (coordinates are absolute screen coordinates)

Example ​

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

const icon = await imageResource("./icon.png");
const win = getActiveWindow();

// Search only within the active window
const matches = await findAllInRegion(
  icon,
  win.x, win.y, win.width, win.height,
  { confidence: 0.75 }
);

Released under the MIT License.