Dragomar
Dragomar

Reputation: 1

C# InputSimulator Library assistance

I am trying to get InputSimulator to simulate holding a key down while another key is held down, and then release when the other key is released.

My code seems so simple, but it does not work. So many similar questions online with no definitive answer other than strangely using an incremented integer in a loop but this does not solve my problem. It needs to hold down L as long as Left Arrow is being held down, and then release when Left arrow is released.

When executed (holding down the left arrow key) the program does output one L, but never more even when holding down LeftArrow the whole time. Why is this? Thank you for your help.

var InputSim = new InputSimulator();

var IsLeftDown = InputSim.InputDeviceState.IsKeyDown(VirtualKeyCode.LEFT);
do
{
    InputSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.VK_L);
    Thread.Sleep(50);
    InputSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.VK_L);
} while (IsLeftDown == true);

Upvotes: 0

Views: 75

Answers (0)

Related Questions