Robot / robot-js

Native system automation for node.js
http://getrobot.net
zlib License
196 stars 24 forks source link

Press multiple keys at the same time. #60

Open ninjabunny-dev opened 6 years ago

ninjabunny-dev commented 6 years ago

I am working on a project where I need to press multiple keys at the same time. I have tried things like.

  keyboard.press(robot.KEY_W);
  keyboard.click(robot.KEY_S);
  keyboard.release(robot.KEY_W);

It doesn't hit them at the same time, I also fiddled with the autoDelay but this made the inputs unreliable. Is there a way to archive this? Any help will be much appreciated.

dkrutsko commented 6 years ago

mmm that should work, I'm not sure why it's not working for you. What operating system is this?

ninjabunny-dev commented 6 years ago

I'm on Windows 10

ninjabunny-dev commented 6 years ago

I am trying to send keys one or two milliseconds apart. I think I might have to use the something lower level than node.

dkrutsko commented 6 years ago

So the keyboard functions are blocking, so the send input's do get executed in the correct order. It's weird that it doesn't in your case.

ninjabunny-dev commented 6 years ago

I set keyboard.autoDelay.min = 10; keyboard.autoDelay.max = 30; and that seemed to do the trick

dkrutsko commented 6 years ago

I'd see if you get the same problem in C++, using either robot or SendInput.