Input plugins
@nut-tree/bolt
Installation
npm i @nut-tree/bolt
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 implementationuseBoltMouse()
: Replaces the default mouse provider with@nut-tree/bolt
's mouse implementationuseBoltScreen()
: Replaces the default screen provider with@nut-tree/bolt
's screen implementationuseBoltWindows()
: Replaces the default window provider with@nut-tree/bolt
's window implementationuseBoltWindowFinder()
: Registers the@nut-tree/bolt
window finder implementation
const { keyboard, imageResource } = require("@nut-tree/nut-js");
const { useBoltKeyboard } = require("@nut-tree/bolt");
useBoltKeyboard(); // From this point on all keyboard interactions will be handled by @nut-tree/bolt
(async () => {
await keyboard.type("@nut-tree/bolt is awesome!");
})();
In case you want to use all available @nut-tree/bolt
providers, you can use the useBolt()
function:
const { screen, imageResource } = require("@nut-tree/nut-js");
const { useBolt } = require("@nut-tree/bolt");
useBolt(); // Now we have all @nut-tree/bolt providers set up, including the window finder
(async () => {
const wnd = await screen.find(windowWithTitle(/some.*regex/));
})();
Unicode Input
@nut-tree/bolt
's keyboard implementation supports unicode input.
Since it's a drop-in replacement for the default keyboard provider, it does not require any additional setup and you can feed unicode symbols right into keyboard.type()
.
const { keyboard, imageResource } = require("@nut-tree/nut-js");
const { useBoltKeyboard } = require("@nut-tree/bolt");
useBoltKeyboard(); // From this point on all keyboard interactions will be handled by @nut-tree/bolt
(async () => {
await keyboard.type("Hello World! 🌍");
})();