Tego Bot API Documentation v0.2.0
Tego Bot API Documentation / waitFor
Function: waitFor()
waitFor(
template,timeout,interval,config?):Promise<MatchResult|null>
Defined in: botjs/src/image-match.ts:448
Wait for a template image to appear on screen
Parameters
template
ImageResource to wait for
timeout
number = 10000
Maximum time to wait in milliseconds (default: 10000)
interval
number = 500
Time between checks in milliseconds (default: 500)
config?
Optional matching configuration
Returns
Promise<MatchResult | null>
Promise resolving to MatchResult when found, or null if timeout
Example
typescript
import { imageResource, waitFor, getMatchCenter, moveMouse, mouseClick } from "@tego/botjs";
const dialog = await imageResource("./dialog.png");
// Wait up to 5 seconds for dialog to appear
const match = await waitFor(dialog, 5000, 250, { confidence: 0.9 });
if (match) {
console.log("Dialog appeared!");
const center = getMatchCenter(match);
moveMouse(center.x, center.y);
mouseClick();
} else {
console.log("Dialog did not appear within timeout");
}