Tego Bot API Documentation v0.2.0
Tego Bot API Documentation / findOnScreen
Function: findOnScreen()
findOnScreen(
template,config?):Promise<MatchResult|null>
Defined in: botjs/src/image-match.ts:223
Find first match of template image on screen
Parameters
template
ImageResource to search for
config?
Optional matching configuration
Returns
Promise<MatchResult | null>
Promise resolving to MatchResult or null if not found
Example
typescript
import { imageResource, findOnScreen, moveMouse, mouseClick } from "@tego/botjs";
const button = await imageResource("./button.png");
const match = await findOnScreen(button, { confidence: 0.85 });
if (match) {
console.log(`Found at (${match.x}, ${match.y}) with ${match.confidence * 100}% confidence`);
const center = getMatchCenter(match);
moveMouse(center.x, center.y);
mouseClick();
} else {
console.log("Button not found on screen");
}