I'm creating a sort of program that holds the letter W in games to avoid AFK penaltie
I tried reading the documentation but is a complete mess. Anyone knows how to do that?
I'm creating a sort of program that holds the letter W in games to avoid AFK penaltie
I tried reading the documentation but is a complete mess. Anyone knows how to do that?
To inject keyboard input, you will need to create a InputInjector class first. It represents the virtual input device for sending the input data. Then you will need to create a InjectedInputKeyboardInfo Class which contains the key input. After that, you could call inputInjector.InjectKeyboardInput
method to inject the keyboard input.
Please also note that the APIs in the Windows.UI.Input.Preview.Injection Namespace require the inputInjectionBrokered
restricted capability.
Here is the code that you could refer to:
InputInjector inputInjector = InputInjector.TryCreate();
var controlkey = new InjectedInputKeyboardInfo();
controlkey.VirtualKey = (ushort)(VirtualKey.LeftControl);
controlkey.KeyOptions = InjectedInputKeyOptions.None;
var altkey = new InjectedInputKeyboardInfo();
altkey.VirtualKey = (ushort)(VirtualKey.Menu);
altkey.KeyOptions = InjectedInputKeyOptions.None;
var delkey = new InjectedInputKeyboardInfo();
delkey.VirtualKey = (ushort)(VirtualKey.Delete);
delkey.KeyOptions = InjectedInputKeyOptions.None;
inputInjector.InjectKeyboardInput(new[] { controlkey, altkey, delkey });
controlkey.KeyOptions = InjectedInputKeyOptions.KeyUp;
altkey.KeyOptions = InjectedInputKeyOptions.KeyUp;
delkey.KeyOptions = InjectedInputKeyOptions.KeyUp;
inputInjector.InjectKeyboardInput(new[] { controlkey, altkey, delkey });