@nut-tree/bolt

Kind: Low-level provider


Installation

1npm i @nut-tree/bolt

Attention: @nut-tree/bolt is only available to sponsors of nut.js.
In case you want to get access to it, please consult the sponsoring profile


Description

@nut-tree/bolt is an alternative low-level provider for nut.js.
It can replace the default @nut-tree/nut-js low-level provider, @nut-tree/libnut, and comes with additional features.

The most significant features at the time of writing are:

  • Unicode support for keyboard input
  • An implementation of the WindowFinderInterface to find windows by title

Usage

@nut-tree/bolt exports a set of functions for fine-grained control over each low-level provider.

  • useBoltKeyboard(): Replaces the default keyboard provider with @nut-tree/bolt's keyboard implementation
  • useBoltMouse(): Replaces the default mouse provider with @nut-tree/bolt's mouse implementation
  • useBoltScreen(): Replaces the default screen provider with @nut-tree/bolt's screen implementation
  • useBoltWindows(): Replaces the default window provider with @nut-tree/bolt's window implementation
  • useBoltWindowFinder(): Registers the @nut-tree/bolt window finder implementation
1const { screen, imageResource } = require("@nut-tree/nut-js");
2const { useBoltKeyboard } = require("@nut-tree/bolt");
3
4useBoltKeyboard(); // From this point on all keyboard interactions will be handled by @nut-tree/bolt
5
6(async () => {
7  const img = await screen.findAll(imageResource("..."));
8})();

In case you want to use all available @nut-tree/bolt providers, you can use the useBolt() function:

1const { screen, imageResource } = require("@nut-tree/nut-js");
2const { useBolt } = require("@nut-tree/bolt");
3
4useBolt(); // Now we have all @nut-tree/bolt providers set up, including the window finder
5
6(async () => {
7    const wnd = await screen.find(windowWithTitle(/some.*regex/));
8})();

© 2023