title: using SendInput in Node-FFI
body: <p>I wanted to use the SendInput function from the windows Api in nodejs, using the FFI package.</p>
  
  <p>My knowledge of C is limited so I can't really figure out what problem I have,
  I'm basically trying to Virtually press a key on the keyboard.</p>
  
  <p>That's the code I have:</p>
  
  <pre><code>var ffi = require('ffi');
  var ref = require ('ref');
  var struct = require ('ref-struct');
  
  var keyboardInput = struct({
      'type': 'int',
      'wVK': 'int',
      'wScan': 'int',
      'dwFlags': 'int',
      'time': 'int',
      'dwExtraInfo': 'int64'
  });
  
  var keyboardInputPtr = ref.refType(keyboardInput);
  var keyboard = new keyboardInput();
  keyboard.type = 1;
  keyboard.wVK = 0x41;
  keyboard.wScan = 0;
  keyboard.dwFlags = 2;
  keyboard.time = 0;
  keyboard.dwExtraInfo = 0;
  
  var user32 = ffi.Library('user32', {
      'SendInput': [ 'int', [ 'uint', keyboardInputPtr, 'int' ] ]
  });
  
  setInterval(function(){
      var r = user32.SendInput(1, keyboard.ref(), 40);
      console.log(r);
  }, 500);
  </code></pre>
  
  <p>It logs me a "1" in the console, shouldn't that mean it works? Because I don't get a key pressed when I open notepad.</p>