我正在创建一种程序,在游戏中保留字母W以避免AFK惩罚我试着阅读documentation,但是完全是一团糟。有人知道怎么做吗?
polkgigr1#
要注入键盘输入,首先需要创建一个**InputInjector class。它表示发送输入数据的虚拟输入设备。然后需要创建一个包含键输入的InjectedInputKeyboardInfo Class**。之后,可以调用inputInjector.InjectKeyboardInput方法来注入键盘输入。另请注意,Windows.UI.Input.Preview.Injection Namespace中的API需要inputInjectionBrokered受限功能。下面是您可以参考的代码:
inputInjector.InjectKeyboardInput
inputInjectionBrokered
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 });
1条答案
按热度按时间polkgigr1#
要注入键盘输入,首先需要创建一个**InputInjector class。它表示发送输入数据的虚拟输入设备。然后需要创建一个包含键输入的InjectedInputKeyboardInfo Class**。之后,可以调用
inputInjector.InjectKeyboardInput
方法来注入键盘输入。另请注意,Windows.UI.Input.Preview.Injection Namespace中的API需要
inputInjectionBrokered
受限功能。下面是您可以参考的代码: