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

后端 未结 5 1905
别跟我提以往
别跟我提以往 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:56

    I've tried robotjs and node-key-sender, but they cause a substantial amount of delay/stuttering per key-event. (especially noticeable when sending them frequently)

    To resolve this, I found a way to use node-ffi-napi to call the Windows user32 SendInput function directly: https://stackoverflow.com/a/50412529/2441655

    In my case at least, this achieved substantially better performance. (however, a drawback is that it only works on Windows, of course)

提交回复
热议问题