Categories
console javascript node.js

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

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 does everything we require, except that – wait-for-user-input prompt. So we wonder (I’m personally very new to NodeJS) if it is possible to execute console module programmatically and trigger an input event on it, so that it doesn’t wait and proceed with the job right away?

You could use possibly use RobotJS for this.

Example code:

var robot = require("robotjs");
// Type user's password or something.
robot.typeString("abc123");