Multiple Search Methods
Find elements by image templates, text OCR, pixel colors, or screen regions.
Automate any game with image recognition, pixel detection, and precise input control. Perfect for E2E testing, QA automation, and regression testing during game development.
Note: Always respect game terms of service. Use responsibly for personal projects, testing, and allowed automation.
import { describe, it, expect } from "vitest";
import {
screen, mouse, Button, keyboard,
straightTo, centerOf, imageResource, sleep
} from "@nut-tree/nut-js";
import { useNlMatcher } from "@nut-tree/nl-matcher";
useNlMatcher();
describe("Main Menu", () => {
it("should start a new game", async () => {
const playBtn = await screen.find(
imageResource("play-button.png")
);
await mouse.move(straightTo(centerOf(playBtn)));
await mouse.click(Button.LEFT);
// Verify loading screen appears
const loading = await screen.find(
imageResource("loading-screen.png")
);
expect(loading).toBeDefined();
});
it("should show the HUD after loading", async () => {
await screen.waitFor(
imageResource("hud-health-bar.png"),
10_000
);
const minimap = await screen.find(
imageResource("minimap.png")
);
expect(minimap).toBeDefined();
});
});nut.js provides the building blocks for sophisticated game automation.
Find elements by image templates, text OCR, pixel colors, or screen regions.
Monitor health bars, mana pools, and status indicators by color.
Configurable mouse movement speed and patterns to avoid detection.
Optimized for real-time game automation with minimal latency.
Read health bars, detect enemies, analyze minimaps, and respond to in-game events instantly.
Pixel color detection
Monitor specific screen locations for color changes
Region capture
Capture specific areas for analysis or processing
Multi-template matching
Search for multiple patterns simultaneously
import { screen, colorAt, Region } from "@nut-tree/nut-js";
// Health bar monitoring
async function monitorHealth() {
const healthBarRegion = new Region(100, 50, 200, 20);
while (true) {
// Get pixel color at health bar position
const healthColor = await colorAt(
screen,
{ x: 150, y: 55 }
);
// Red = low health, Green = full health
if (healthColor.R > 200 && healthColor.G < 100) {
await useHealthPotion();
}
await sleep(100);
}
}
// Screen region capture for analysis
async function analyzeGameState() {
const minimapRegion = new Region(1720, 800, 200, 200);
const minimap = await screen.grabRegion(minimapRegion);
// Process minimap for enemy positions, etc.
}Validate complete gameplay flows end-to-end—from menu navigation to in-game interactions—across platforms.
Catch visual and functional regressions between builds by replaying test scenarios automatically after every release.
Reduce manual QA effort by scripting repetitive test cases like UI checks, tutorial flows, and settings verification.
Script complex in-game sequences for stress testing, performance benchmarking, or reproducing hard-to-trigger bugs.
Get started with nut.js and build sophisticated game automation in minutes.