Description
Version
@nut-tree/nut-js": "^1.4.1"
Short overview
Following an example on trailmix under "type" (https://github.com/nut-tree/trailmix/tree/master/packages/keyboard-test) I try to open Spotlight and then type. However, it seems that when trying to do this with keyboard.type("string") it very rarely works, or it types part of the string, etc.
Issue occurs on
- Virtual machine
- Docker container
- Dev/Host system
Detailed error description
Following an example on trailmix under "type" (https://github.com/nut-tree/trailmix/tree/master/packages/keyboard-test) I try to open Spotlight and then type. However, it seems that when trying to do this with keyboard.type("string") it very rarely works, or it types part of the string, etc.
Using "keyboard.type(Key.S, Key.T.. etc)" seems to work no problem, so it seems to be an issue with passing in a String to the keyboard.type function.
Steps to reproduce error
(async () => {
const { mouse, keyboard, Key, screen, right, down, left, up } = require("@nut-tree/nut-js");
keyboard.config.autoDelayMs = 250;
// this takes in a string and types it out using the Key. method rather than by string
const hackFix = async (string) => {
string.split("").forEach(async (char) => {
const character = char.toUpperCase()
await keyboard.type(Key[character])
});
}
try {
await keyboard.type(Key.LeftSuper, Key.Space); // bring up spotlight
await keyboard.type("calculator"); // this doesn't work
await hackFix("CALCULATOR") // this works
await keyboard.pressKey(Key.Enter);
await keyboard.releaseKey(Key.Enter);
} catch (e) {
console.log(e)
}
})();
Additional content
N/A