Skip to content

Issue with keyboard.type in to Spotlight on MacOS (Catalina) #152

Description

@jackroberts-gh

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions