Input Simulator / VirtualKeyCode does not exists

Jun 10, 2012 at 3:09 PM

Hi , i just tried to do send a key if I press a button

  private void button1_Click_1(object sender, EventArgs e)     

  {   

        InputSimulator.SimulateKeyPress(VirtualKeyCode.SPACE);   

    }

 

But i get:
Error 2 The name 'VirtualKeyCode' does not exist in the current context

Error 1 The name 'InputSimulator' does not exist in the current context

 

What should I do?

Jun 12, 2012 at 4:56 AM

You should add

using WindowsInput.Native;

to fix the first problem.
As for the second, create an instance of the InputSimulator class before you start using it.

TheInputSimulator = new InputSimulator();

TheInputSimulator.Keyboard.KeyPress(VirtualKeyCode.SPACE);

Note that the examples on the front page are outdated. If you don't have intellisense to
help out with composing the function calls then I guess you should look inside the
InputSimulator and the related classes to see what's what.