diff --git a/BetterGenshinImpact/Core/Config/KeyBindingsConfig.cs b/BetterGenshinImpact/Core/Config/KeyBindingsConfig.cs
index 87910001..9c022f6c 100644
--- a/BetterGenshinImpact/Core/Config/KeyBindingsConfig.cs
+++ b/BetterGenshinImpact/Core/Config/KeyBindingsConfig.cs
@@ -1,6 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System;
+using System.Windows.Forms;
using System.Windows.Input;
+using Windows.Networking.PushNotifications;
using static Vanara.PInvoke.User32;
namespace BetterGenshinImpact.Core.Config;
@@ -490,6 +492,22 @@ public static class KeyIdConverter
};
}
+ ///
+ /// [实验] 将KeyId转换为WinForm中的Keys(用于兼容按键连发功能)
+ ///
+ ///
+ ///
+ public static Keys ToWinFormKeys(this KeyId value)
+ {
+ try
+ {
+ return Enum.Parse(value.ToInputKey().ToString());
+ }
+ catch
+ {
+ return default;
+ }
+ }
///
/// 将VK转换为KeyId
diff --git a/BetterGenshinImpact/Core/Monitor/MouseKeyMonitor.cs b/BetterGenshinImpact/Core/Monitor/MouseKeyMonitor.cs
index bce0f404..d9b91a0c 100644
--- a/BetterGenshinImpact/Core/Monitor/MouseKeyMonitor.cs
+++ b/BetterGenshinImpact/Core/Monitor/MouseKeyMonitor.cs
@@ -1,4 +1,5 @@
-using BetterGenshinImpact.Core.Recorder;
+using BetterGenshinImpact.Core.Config;
+using BetterGenshinImpact.Core.Recorder;
using BetterGenshinImpact.Core.Simulator;
using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.Model;
@@ -18,6 +19,10 @@ public class MouseKeyMonitor
///
private readonly Timer _fTimer = new();
+ private Keys _pickUpKey = Keys.F;
+
+ private User32.VK _pickUpKeyCode = User32.VK.VK_F;
+
//private readonly Random _random = new();
///
@@ -25,6 +30,10 @@ public class MouseKeyMonitor
///
private readonly Timer _spaceTimer = new();
+ private Keys _releaseControlKey = Keys.Space;
+
+ private User32.VK _releaseControlKeyCode = User32.VK.VK_SPACE;
+
private DateTime _firstFKeyDownTime = DateTime.MaxValue;
///
@@ -49,14 +58,19 @@ public class MouseKeyMonitor
_globalHook.MouseWheelExt += GlobalHookMouseWheelExt;
//_globalHook.KeyPress += GlobalHookKeyPress;
+ _pickUpKey = TaskContext.Instance().Config.KeyBindingsConfig.PickUpOrInteract.ToWinFormKeys();
+ _pickUpKeyCode = TaskContext.Instance().Config.KeyBindingsConfig.PickUpOrInteract.ToVK();
+ _releaseControlKey = TaskContext.Instance().Config.KeyBindingsConfig.Jump.ToWinFormKeys();
+ _releaseControlKeyCode = TaskContext.Instance().Config.KeyBindingsConfig.Jump.ToVK();
+
_firstSpaceKeyDownTime = DateTime.MaxValue;
var si = TaskContext.Instance().Config.MacroConfig.SpaceFireInterval;
_spaceTimer.Interval = si;
- _spaceTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(User32.VK.VK_SPACE); };
+ _spaceTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(_releaseControlKeyCode); };
var fi = TaskContext.Instance().Config.MacroConfig.FFireInterval;
_fTimer.Interval = fi;
- _fTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(User32.VK.VK_F); };
+ _fTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(_pickUpKeyCode); };
}
private void GlobalHookKeyDown(object? sender, KeyEventArgs e)
@@ -67,7 +81,7 @@ public class MouseKeyMonitor
// 热键按下事件
HotKeyDown(sender, e);
- if (e.KeyCode == Keys.Space)
+ if (e.KeyCode == _releaseControlKey)
{
if (_firstSpaceKeyDownTime == DateTime.MaxValue)
{
@@ -81,7 +95,7 @@ public class MouseKeyMonitor
_spaceTimer.Start();
}
}
- else if (e.KeyCode == Keys.F)
+ else if (e.KeyCode == _pickUpKey)
{
if (_firstFKeyDownTime == DateTime.MaxValue)
{