Search code examples
c#minecraftsendkeys

C# Send key inputs to Minecraft to move the player


I am trying to send keyboard inputs to Minecraft to move the player, however when I try using SendKeys.SendWait("W"); nothing happens. If I open the chat in Minecraft it types "W" in chat, however outside of chat my inputs seem to be ignored. Thanks.

Edit: I have tried using SendInput as well as InputSimulator both having the same effect.


Solution

  • I solved it by using InputSimulatorPlus

    https://github.com/TChatzigiannakis/InputSimulatorPlus

    InputSimulator s = new InputSimulator(); s.Keyboard.KeyDown(VirtualKeyCode.VK_W);

    this just runs forward, to stop use s.Keyboard.KeyUp(VirtualKeyCode.VK_W); you can also use s.Keyboard.KeyPress(VirtualKeyCode.VK_W); and this will just click the "W" key.