Core concepts

The nut.js philosophy

nut.js is a desktop automation framework. It allows you to program your computer using JavaScript or TypeScript by imitating real user input.

And this is also the core concept of nut.js. It does not go overboard with abstract interactions, it rather relies on simple building blocks which allow you to assemble complex actions from.

There's no magical click function to click whichever element you're targeting. But you can build it up yourself by focusing on the workflow a human would follow.

  • You identify the window you want to target
  • You focus the window
  • You locate the button
  • You move the mouse over the button
  • You perform the click

This roughly translate to something like the following code snippet:

import {screen, mouse, windowWithTitle, Button, singleWord, straightTo, centerOf} from "@nut-tree/nut-js";
import {useBoltWindowFinder} from "@nut-tree/bolt";
import {configure, LanguageModelType} from "@nut-tree/plugin-ocr";

    languageModelType: LanguageModelType.BEST,

screen.config.ocrConfidence = 0.85;


const webstorm = await screen.find(windowWithTitle(/nut.js – .*/));
await webstorm.focus();
const windowFileLocation = await screen.find(singleWord("window.class.ts"), {searchRegion: webstorm.region});
await mouse.move(straightTo(centerOf(windowFileLocation)));

As you can see, single pieces of functionality provided by nut.js can be pieced together to provide the big picture. Allowing you to think in steps just like a human would do.

That's the philosophy of nut.js!

Solving complex tasks one step at a time.

You can take it from here and build up your own functions to encapsulate repeating workflows, but I hope this simple example gives you an understanding how nut.js is designed and how to go with its philosophy!