0

Like this question, I am trying to figure out how to simulate certain key commands with NodeJS. For example, I'd like to programmatically cause "ctrl+C" (copying highlighted text) to occur, no matter what window the user is in.

A common answer to this kind of question previously has been RobotJS. RobotJS seems perfectly suited to this task--except it is no longer being maintained and as a result does not seem appropriate for production.

Are there alternatives to RobotJS, to enable causing key commands to happen?

SeanRtS
  • 1,005
  • 1
  • 13
  • 31

1 Answers1

0

There are a few options I'm aware of:

  • @nut-tree/nut-js uses its own implementation based off of RobotJS and seems to be actively maintained.
  • If you don't mind platform-specific utilities, you could execute native scripts through Node.js child processes (AppleScript, PowerShell, etc.)
Erick
  • 1,138
  • 8
  • 15
  • Thanks for your reply. I've seen references to child processes like you mentioned (AppleScript, and maybe with spawn). But I don't have a good sense of what that would involve. Are you familiar with any example code for that ? – SeanRtS Apr 14 '21 at 21:51
  • There are a couple NPM libraries out there that can help you out with that (e.g. https://www.npmjs.com/package/node-powershell or https://www.npmjs.com/package/applescript – Erick Apr 14 '21 at 23:00