From dff7d588737892e7112cccfbadc9aec24c4c2aec Mon Sep 17 00:00:00 2001 From: ema Date: Tue, 19 Dec 2023 00:01:47 +0800 Subject: [PATCH] `NumEnter` key support was added to the Fischless.WindowsInput --- .../GameTask/AutoWood/AutoWoodTask.cs | 9 +++------ .../Genshin/Settings/OverrideController.cs | 5 +++-- Fischless.WindowsInput/InputBuilder.cs | 12 +++++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs b/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs index c1ea7fed..23a36f61 100644 --- a/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs +++ b/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs @@ -30,8 +30,6 @@ public class AutoWoodTask private VK _zKey = VK.VK_Z; - private bool? _zIsExt = null; - public AutoWoodTask() { var captureArea = TaskContext.Instance().SystemInfo.CaptureAreaRect; @@ -59,7 +57,6 @@ public class AutoWoodTask if (key != ElementIdentifierId.Z) { _zKey = key.ToVK(); - _zIsExt = key.ToIsExt(); Logger.LogInformation($"自动伐木检测到用户改键 {ElementIdentifierId.Z.ToName()} 改为 {key.ToName()}"); if (key == ElementIdentifierId.LeftShift || key == ElementIdentifierId.RightShift) { @@ -127,14 +124,14 @@ public class AutoWoodTask throw new NormalEndException("请先装备小道具「王树瑞佑」!"); #else Thread.Sleep(2000); - Simulation.SendInputEx.Keyboard.KeyPress(_zIsExt, _zKey); + Simulation.SendInputEx.Keyboard.KeyPress(_zKey); Debug.WriteLine("[AutoWood] Z"); _first = false; #endif } else { - Simulation.SendInputEx.Keyboard.KeyPress(_zIsExt, _zKey); + Simulation.SendInputEx.Keyboard.KeyPress(_zKey); Debug.WriteLine("[AutoWood] Z"); _first = false; } @@ -155,7 +152,7 @@ public class AutoWoodTask #endif } - Simulation.SendInputEx.Keyboard.KeyPress(_zIsExt, _zKey); + Simulation.SendInputEx.Keyboard.KeyPress(_zKey); Debug.WriteLine("[AutoWood] Z"); Sleep(500, taskParam.Cts); }, TimeSpan.FromSeconds(1), 120); diff --git a/BetterGenshinImpact/Genshin/Settings/OverrideController.cs b/BetterGenshinImpact/Genshin/Settings/OverrideController.cs index 2a17fd0c..fb2d8bda 100644 --- a/BetterGenshinImpact/Genshin/Settings/OverrideController.cs +++ b/BetterGenshinImpact/Genshin/Settings/OverrideController.cs @@ -1,4 +1,5 @@ -using System; +using Fischless.WindowsInput; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -405,7 +406,7 @@ public static class ElementIdentifierIdConverter ElementIdentifierId.NumpadAsterisk => VK.VK_MULTIPLY, ElementIdentifierId.NumpadMinus => VK.VK_SUBTRACT, ElementIdentifierId.NumpadPlus => VK.VK_ADD, - ElementIdentifierId.NumpadEnter => VK.VK_RETURN, + ElementIdentifierId.NumpadEnter => (VK)VK2.VK_NUMPAD_ENTER, ElementIdentifierId.ArrowUp => VK.VK_UP, ElementIdentifierId.ArrowDown => VK.VK_DOWN, ElementIdentifierId.ArrowRight => VK.VK_RIGHT, diff --git a/Fischless.WindowsInput/InputBuilder.cs b/Fischless.WindowsInput/InputBuilder.cs index f8306b2b..b0439829 100644 --- a/Fischless.WindowsInput/InputBuilder.cs +++ b/Fischless.WindowsInput/InputBuilder.cs @@ -1,5 +1,6 @@ using System.Collections; using Vanara.PInvoke; +using static Vanara.PInvoke.User32; namespace Fischless.WindowsInput; @@ -55,7 +56,7 @@ internal class InputBuilder : IEnumerable, IEnumerable { bool isUseExtendedKey = isExtendedKey == null ? IsExtendedKey(keyCode) : isExtendedKey.Value; - if ((VK2)keyCode == VK2.NumEnter) + if ((VK2)keyCode == VK2.VK_NUMPAD_ENTER) { keyCode = User32.VK.VK_RETURN; isUseExtendedKey = true; @@ -82,7 +83,7 @@ internal class InputBuilder : IEnumerable, IEnumerable { bool isUseExtendedKey = isExtendedKey == null ? IsExtendedKey(keyCode) : isExtendedKey.Value; - if ((VK2)keyCode == VK2.NumEnter) + if ((VK2)keyCode == VK2.VK_NUMPAD_ENTER) { keyCode = User32.VK.VK_RETURN; isUseExtendedKey = true; @@ -364,8 +365,13 @@ internal class InputBuilder : IEnumerable, IEnumerable /// public enum VK2 { + /// + /// ENTER key + /// + VK_ENTER = VK.VK_RETURN, + /// /// The Unassigned code: The Num ENTER key. /// - NumEnter = 0x0E, + VK_NUMPAD_ENTER = 0x0E, }