Is it possible to simulate keyboard/mouse event in NodeJS?

后端 未结 5 1913
别跟我提以往
别跟我提以往 2020-12-06 10:07

Imagine that a NodeJS module, when invoked from console, outputs some introductory messages and then waits for user input (click enter or esc). This module already has and d

5条回答
  •  情话喂你
    2020-12-06 10:52

    As Jason mentioned you could use RobotJS for key simulation but there are couple of steps require to correctly build robotJS for Windows paltform:

    1. You would need windows build tools so run npm install --global windows-build-tools (would take some time as it's around 120MB)
    2. run npm install robotjs --save-dev
      You're done!.
      If this is for electron app then you would also require below 3rd step:
    3. run npm rebuild --runtime=electron --target=1.7.9 --disturl=https://atom.io/download/atom-shell --abi=57

      (1.7.9 is my electron --version and abi is for my corresponding node --version 8.7 installed, you can check abi version for node version here [look for NODE_MODULE_VERSION column])

提交回复
热议问题