From 9378a134bd6064c5b549db18f007d082372bb8be Mon Sep 17 00:00:00 2001 From: ema Date: Sun, 12 May 2024 05:16:27 +0800 Subject: [PATCH] remove: package `H.InputSimulator` #154 --- .../BetterGenshinImpact.csproj | 1 - .../Core/Simulator/Simulation.cs | 7 +-- .../GameTask/AutoDomain/AutoDomainTask.cs | 14 +++--- .../GameTask/AutoFight/Model/Avatar.cs | 12 ++--- .../AutoFishing/AutoFishingTrigger.cs | 46 +++++++++---------- .../GeniusInvokationControl.cs | 2 +- .../AutoMusicGame/AutoMusicGameTask.cs | 4 +- .../GameTask/AutoPick/AutoPickTrigger.cs | 4 +- .../GameTask/AutoSkip/AutoSkipTrigger.cs | 6 +-- .../GameTask/AutoSkip/AutoTrackTask.cs | 18 ++++---- .../GameTask/AutoSkip/OneKeyExpeditionTask.cs | 2 +- .../GameTask/AutoWood/AutoWoodTask.cs | 6 +-- .../GameTask/GameLoading/GameLoading.cs | 2 +- .../GameTask/Macro/TurnAroundMacro.cs | 2 +- .../GameTask/Model/Area/DesktopRegion.cs | 6 +-- .../GameTask/QucikBuy/QuickBuyTask.cs | 6 +-- .../QuickSereniteaPotTask.cs | 4 +- .../Helpers/Extensions/ClickExtension.cs | 6 +-- Fischless.KeyboardCapture/KeyboardReader.cs | 5 +- 19 files changed, 74 insertions(+), 79 deletions(-) diff --git a/BetterGenshinImpact/BetterGenshinImpact.csproj b/BetterGenshinImpact/BetterGenshinImpact.csproj index 1b30cbe4..0e164cdf 100644 --- a/BetterGenshinImpact/BetterGenshinImpact.csproj +++ b/BetterGenshinImpact/BetterGenshinImpact.csproj @@ -30,7 +30,6 @@ - diff --git a/BetterGenshinImpact/Core/Simulator/Simulation.cs b/BetterGenshinImpact/Core/Simulator/Simulation.cs index a0481c2d..9939ef9f 100644 --- a/BetterGenshinImpact/Core/Simulator/Simulation.cs +++ b/BetterGenshinImpact/Core/Simulator/Simulation.cs @@ -1,15 +1,12 @@ -using System; -using WindowsInput; +using Fischless.WindowsInput; +using System; namespace BetterGenshinImpact.Core.Simulator; public class Simulation { - [Obsolete] public static InputSimulator SendInput { get; } = new(); - public static Fischless.WindowsInput.InputSimulator SendInputEx { get; } = new(); - public static MouseEventSimulator MouseEvent { get; } = new(); public static PostMessageSimulator PostMessage(IntPtr hWnd) diff --git a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs index 46849554..70134dc2 100644 --- a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs +++ b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs @@ -191,7 +191,7 @@ public class AutoDomainTask using var fRectArea = GetRectAreaFromDispatcher().Find(AutoPickAssets.Instance.FRo); if (!fRectArea.IsEmpty()) { - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_F); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_F); Logger.LogInformation("自动秘境:{Text}", "进入秘境"); // 秘境开门动画 5s Sleep(5000, _taskParam.Cts); @@ -254,7 +254,7 @@ public class AutoDomainTask // 组合键好像不能直接用 postmessage if (!_config.WalkToF) { - Simulation.SendInputEx.Keyboard.KeyDown(VK.VK_SHIFT); + Simulation.SendInput.Keyboard.KeyDown(VK.VK_SHIFT); } try @@ -269,7 +269,7 @@ public class AutoDomainTask else { Logger.LogInformation("检测到交互键"); - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_F); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_F); break; } } @@ -280,7 +280,7 @@ public class AutoDomainTask Sleep(50); if (!_config.WalkToF) { - Simulation.SendInputEx.Keyboard.KeyUp(VK.VK_SHIFT); + Simulation.SendInput.Keyboard.KeyUp(VK.VK_SHIFT); } } }); @@ -399,7 +399,7 @@ public class AutoDomainTask CancellationTokenSource treeCts = new CancellationTokenSource(); _taskParam.Cts.Token.Register(treeCts.Cancel); // 中键回正视角 - Simulation.SendInputEx.Mouse.MiddleButtonClick(); + Simulation.SendInput.Mouse.MiddleButtonClick(); Sleep(900, _taskParam.Cts); // 左右移动直到石化古树位于屏幕中心任务 @@ -612,7 +612,7 @@ public class AutoDomainTask moveAngle *= 2; } - Simulation.SendInputEx.Mouse.MoveMouseBy(-moveAngle, 0); + Simulation.SendInput.Mouse.MoveMouseBy(-moveAngle, 0); continuousCount = 0; } else if (angle is > 180 and < 360) @@ -624,7 +624,7 @@ public class AutoDomainTask moveAngle *= 2; } - Simulation.SendInputEx.Mouse.MoveMouseBy(moveAngle, 0); + Simulation.SendInput.Mouse.MoveMouseBy(moveAngle, 0); continuousCount = 0; } else diff --git a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs index f8c52fcf..757601d0 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs @@ -108,9 +108,9 @@ public class Avatar using var confirmRectArea = region.Find(AutoFightContext.Instance.FightAssets.ConfirmRa); if (!confirmRectArea.IsEmpty()) { - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_ESCAPE); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE); Sleep(600, Cts); - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_M); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_M); throw new Exception("存在角色被击败,按 M 键打开地图,并停止自动秘境。"); } } @@ -260,7 +260,7 @@ public class Avatar Sleep(300, Cts); for (int j = 0; j < 10; j++) { - Simulation.SendInputEx.Mouse.MoveMouseBy(1000, 0); + Simulation.SendInput.Mouse.MoveMouseBy(1000, 0); Sleep(50); // 持续操作不应该被cts取消 } @@ -419,7 +419,7 @@ public class Avatar /// public void MoveCamera(int pixelDeltaX, int pixelDeltaY) { - Simulation.SendInputEx.Mouse.MoveMouseBy(pixelDeltaX, pixelDeltaY); + Simulation.SendInput.Mouse.MoveMouseBy(pixelDeltaX, pixelDeltaY); } /// @@ -459,7 +459,7 @@ public class Avatar return; } - Simulation.SendInputEx.Mouse.MoveMouseBy(1000, 0); + Simulation.SendInput.Mouse.MoveMouseBy(1000, 0); ms -= 50; Sleep(50); // 持续操作不应该被cts取消 } @@ -527,7 +527,7 @@ public class Avatar public void MoveBy(int x, int y) { - Simulation.SendInputEx.Mouse.MoveMouseBy(x, y); + Simulation.SendInput.Mouse.MoveMouseBy(x, y); } public void KeyDown(string key) diff --git a/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingTrigger.cs b/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingTrigger.cs index 18bdfecc..1abda10d 100644 --- a/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingTrigger.cs +++ b/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingTrigger.cs @@ -273,18 +273,18 @@ namespace BetterGenshinImpact.GameTask.AutoFishing // 往左移动是正数,往右移动是负数 if (fishpond.FishpondRect.Left > centerX) { - Simulation.SendInputEx.Mouse.MoveMouseBy(100, 0); + Simulation.SendInput.Mouse.MoveMouseBy(100, 0); } if (fishpond.FishpondRect.Right < centerX) { - Simulation.SendInputEx.Mouse.MoveMouseBy(-100, 0); + Simulation.SendInput.Mouse.MoveMouseBy(-100, 0); } // 鱼塘尽量在上半屏幕 if (fishpond.FishpondRect.Bottom > centerY) { - Simulation.SendInputEx.Mouse.MoveMouseBy(0, -100); + Simulation.SendInput.Mouse.MoveMouseBy(0, -100); } if ((fishpond.FishpondRect.Left < centerX && fishpond.FishpondRect.Right > centerX && fishpond.FishpondRect.Bottom >= centerY) || fishpond.FishpondRect.Width < content.CaptureRectArea.SrcBitmap.Width / 4) @@ -322,7 +322,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing // 30s 没有上钩,重新抛竿 if (_throwRodWaitFrameNum >= content.FrameRate * TaskContext.Instance().Config.AutoFishingConfig.AutoThrowRodTimeOut) { - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _throwRodWaitFrameNum = 0; _waitBiteContinuouslyFrameNum = 0; Debug.WriteLine("超时自动收竿"); @@ -365,9 +365,9 @@ namespace BetterGenshinImpact.GameTask.AutoFishing private string ChooseBait(CaptureContent content, Fishpond fishpond) { // 打开换饵界面 - Simulation.SendInputEx.Mouse.RightButtonClick(); + Simulation.SendInput.Mouse.RightButtonClick(); Sleep(100); - Simulation.SendInputEx.Mouse.MoveMouseBy(0, 200); // 鼠标移走,防止干扰 + Simulation.SendInput.Mouse.MoveMouseBy(0, 200); // 鼠标移走,防止干扰 Sleep(500); _selectedBaitName = fishpond.Fishes[0].FishType.BaitName; // 选择最多鱼吃的饵料 @@ -417,7 +417,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing private void ApproachFishAndThrowRod(CaptureContent content) { // 预抛竿 - Simulation.SendInputEx.Mouse.LeftButtonDown(); + Simulation.SendInput.Mouse.LeftButtonDown(); _logger.LogInformation("长按预抛竿"); Sleep(3000); @@ -451,7 +451,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing var moveX = 100 * (cX - rdX) / ra.SrcBitmap.Width; var moveY = 100 * (cY - rdY) / ra.SrcBitmap.Height; - Simulation.SendInputEx.Mouse.MoveMouseBy(moveX, moveY); + Simulation.SendInput.Mouse.MoveMouseBy(moveX, moveY); if (noPlacementTimes > 25) { @@ -503,10 +503,10 @@ namespace BetterGenshinImpact.GameTask.AutoFishing { // 没有找到目标鱼,重新选择鱼饵 _logger.LogInformation("没有找到目标鱼,1.直接抛竿"); - Simulation.SendInputEx.Mouse.LeftButtonUp(); + Simulation.SendInput.Mouse.LeftButtonUp(); Sleep(1500); _logger.LogInformation("没有找到目标鱼,2.收杆"); - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); Sleep(800); _logger.LogInformation("没有找到目标鱼,3.准备重新选择鱼饵"); _selectedBaitName = string.Empty; @@ -569,12 +569,12 @@ namespace BetterGenshinImpact.GameTask.AutoFishing var moveY = 100 * (cY - rdY) / content.CaptureRectArea.SrcBitmap.Height; _logger.LogInformation("失败 随机移动 {DX}, {DY}", moveX, moveY); - Simulation.SendInputEx.Mouse.MoveMouseBy(moveX, moveY); + Simulation.SendInput.Mouse.MoveMouseBy(moveX, moveY); } else if (state == 0) { // 成功 抛竿 - Simulation.SendInputEx.Mouse.LeftButtonUp(); + Simulation.SendInput.Mouse.LeftButtonUp(); _logger.LogInformation("尝试钓取 {Text}", currentFish.FishType.ChineseName); _isThrowRod = true; VisionContext.Instance().DrawContent.RemoveRect("Target"); @@ -589,13 +589,13 @@ namespace BetterGenshinImpact.GameTask.AutoFishing dx = dx / dl * 30; dy = dy / dl * 30; // _logger.LogInformation("太近 移动 {DX}, {DY}", dx, dy); - Simulation.SendInputEx.Mouse.MoveMouseBy((int)(-dx / 1.5), (int)(-dy * 1.5)); + Simulation.SendInput.Mouse.MoveMouseBy((int)(-dx / 1.5), (int)(-dy * 1.5)); } else if (state == 2) { // 太远 // _logger.LogInformation("太远 移动 {DX}, {DY}", dx, dy); - Simulation.SendInputEx.Mouse.MoveMouseBy((int)(dx / 1.5), (int)(dy * 1.5)); + Simulation.SendInput.Mouse.MoveMouseBy((int)(dx / 1.5), (int)(dy * 1.5)); } } @@ -621,9 +621,9 @@ namespace BetterGenshinImpact.GameTask.AutoFishing if (TaskContext.Instance().Config.AutoFishingConfig.AutoThrowRodEnabled) { // 下移视角方便看鱼 - Simulation.SendInputEx.Mouse.MoveMouseBy(0, 400); + Simulation.SendInput.Mouse.MoveMouseBy(0, 400); Sleep(500); - Simulation.SendInputEx.Mouse.MoveMouseBy(0, 500); + Simulation.SendInput.Mouse.MoveMouseBy(0, 500); Sleep(500); } } @@ -661,7 +661,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing } //_logger.LogInformation("移动鼠标 {X} {Y}", 0, moveY); - Simulation.SendInputEx.Mouse.MoveMouseBy(0, moveY); + Simulation.SendInput.Mouse.MoveMouseBy(0, moveY); return (0, minDistance); } @@ -681,7 +681,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing } //_logger.LogInformation("移动鼠标 {X} {Y}", moveX, 0); - Simulation.SendInputEx.Mouse.MoveMouseBy(moveX, 0); + Simulation.SendInput.Mouse.MoveMouseBy(moveX, 0); return (minDistance, 0); } @@ -714,7 +714,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing } //_logger.LogInformation("移动鼠标 {X} {Y}", moveX, moveY); - Simulation.SendInputEx.Mouse.MoveMouseBy(moveX, moveY); + Simulation.SendInput.Mouse.MoveMouseBy(moveX, moveY); return (dpX, dpY); } @@ -846,7 +846,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing using var liftRodButtonRa = content.CaptureRectArea.Find(_autoFishingAssets.LiftRodButtonRo); if (!liftRodButtonRa.IsEmpty()) { - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _logger.LogInformation(@"┌------------------------┐"); _logger.LogInformation(" 自动提竿(图像识别)"); _isFishingProcess = true; @@ -863,7 +863,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing currentBiteWordsTips.Width, currentBiteWordsTips.Height))); if (!string.IsNullOrEmpty(text) && StringUtils.RemoveAllSpace(text).Contains("上钩")) { - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _logger.LogInformation(@"┌------------------------┐"); _logger.LogInformation(" 自动提竿(OCR)"); _isFishingProcess = true; @@ -882,7 +882,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing if (_biteTipsExitCount >= content.FrameRate / 2d) { - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _logger.LogInformation(@"┌------------------------┐"); _logger.LogInformation(" 自动提竿(文字块)"); _isFishingProcess = true; @@ -906,7 +906,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing /// private void Fishing(CaptureContent content, Mat fishBarMat) { - var simulator = Simulation.SendInputEx; + var simulator = Simulation.SendInput; var rects = AutoFishingImageRecognition.GetFishBarRect(fishBarMat); if (rects != null && rects.Count > 0) { diff --git a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs index 1647fa00..a9f4c2d4 100644 --- a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs +++ b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs @@ -539,7 +539,7 @@ public class GeniusInvokationControl public void ActionPhaseElementalTuning(int currentCardCount) { var rect = TaskContext.Instance().SystemInfo.CaptureAreaRect; - var m = Simulation.SendInputEx.Mouse; + var m = Simulation.SendInput.Mouse; ClickExtension.Click(rect.X + rect.Width / 2d, rect.Y + rect.Height - 50); Sleep(1500); if (currentCardCount == 1) diff --git a/BetterGenshinImpact/GameTask/AutoMusicGame/AutoMusicGameTask.cs b/BetterGenshinImpact/GameTask/AutoMusicGame/AutoMusicGameTask.cs index f8a79ba3..eca0b3a7 100644 --- a/BetterGenshinImpact/GameTask/AutoMusicGame/AutoMusicGameTask.cs +++ b/BetterGenshinImpact/GameTask/AutoMusicGame/AutoMusicGameTask.cs @@ -118,12 +118,12 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) private void KeyUp(User32.VK key) { - Simulation.SendInputEx.Keyboard.KeyUp(key); + Simulation.SendInput.Keyboard.KeyUp(key); } private void KeyDown(User32.VK key) { - Simulation.SendInputEx.Keyboard.KeyDown(key); + Simulation.SendInput.Keyboard.KeyDown(key); } private void Init() diff --git a/BetterGenshinImpact/GameTask/AutoPick/AutoPickTrigger.cs b/BetterGenshinImpact/GameTask/AutoPick/AutoPickTrigger.cs index 368b0ae2..7340fbaa 100644 --- a/BetterGenshinImpact/GameTask/AutoPick/AutoPickTrigger.cs +++ b/BetterGenshinImpact/GameTask/AutoPick/AutoPickTrigger.cs @@ -175,7 +175,7 @@ public class AutoPickTrigger : ITaskTrigger if (_whiteList.Contains(text)) { LogPick(content, text); - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_F); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_F); return; } @@ -195,7 +195,7 @@ public class AutoPickTrigger : ITaskTrigger speedTimer.Record("黑名单判断"); LogPick(content, text); - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_F); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_F); } }); speedTimer.DebugPrint(); diff --git a/BetterGenshinImpact/GameTask/AutoSkip/AutoSkipTrigger.cs b/BetterGenshinImpact/GameTask/AutoSkip/AutoSkipTrigger.cs index e44cce97..02442f11 100644 --- a/BetterGenshinImpact/GameTask/AutoSkip/AutoSkipTrigger.cs +++ b/BetterGenshinImpact/GameTask/AutoSkip/AutoSkipTrigger.cs @@ -182,7 +182,7 @@ public class AutoSkipTrigger : ITaskTrigger _prevPlayingTime = DateTime.Now; if (TaskContext.Instance().Config.AutoSkipConfig.QuicklySkipConversationsEnabled) { - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_SPACE); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE); } // 对话选项选择 @@ -221,7 +221,7 @@ public class AutoSkipTrigger : ITaskTrigger var rate = blackCount * 1d / (grayMat.Width * grayMat.Height); if (rate is >= 0.5 and < 0.98999) { - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _logger.LogInformation("自动剧情:{Text} 比例 {Rate}", "点击黑屏", rate.ToString("F")); @@ -367,7 +367,7 @@ public class AutoSkipTrigger : ITaskTrigger content.CaptureRectArea.Find(_autoSkipAssets.PrimogemRo, primogemRa => { Thread.Sleep(100); - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_ESCAPE); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE); _prevGetDailyRewardsTime = DateTime.MinValue; primogemRa.Dispose(); }); diff --git a/BetterGenshinImpact/GameTask/AutoSkip/AutoTrackTask.cs b/BetterGenshinImpact/GameTask/AutoSkip/AutoTrackTask.cs index 62feb807..cfc1e4e2 100644 --- a/BetterGenshinImpact/GameTask/AutoSkip/AutoTrackTask.cs +++ b/BetterGenshinImpact/GameTask/AutoSkip/AutoTrackTask.cs @@ -92,7 +92,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask } // 任务文字有动效,等待2s重新截图 - Simulation.SendInputEx.Mouse.MoveMouseBy(0, 7000); + Simulation.SendInput.Mouse.MoveMouseBy(0, 7000); Sleep(2000, param.Cts); // OCR 任务文字 在小地图下方 @@ -111,7 +111,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask { // 距离大于150米,先传送到最近的传送点 // J 打开任务 切换追踪打开地图 中心点就是任务点 - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_J); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_J); Sleep(800, param.Cts); // TODO 识别是否在任务界面 // 切换追踪 @@ -177,7 +177,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask private void StartTrackPoint() { // V键直接追踪 - Simulation.SendInputEx.Keyboard.KeyPress(User32.VK.VK_V); + Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_V); Sleep(3000, param.Cts); var ra = GetRectAreaFromDispatcher(); @@ -211,10 +211,10 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask var centerY = blueTrackPointRa.Y + blueTrackPointRa.Height / 2; if (centerY > CaptureRect.Height / 2) { - Simulation.SendInputEx.Mouse.MoveMouseBy(-50, 0); + Simulation.SendInput.Mouse.MoveMouseBy(-50, 0); if (wDown) { - Simulation.SendInputEx.Keyboard.KeyUp(User32.VK.VK_W); + Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W); wDown = false; } Debug.WriteLine("使追踪点位于俯视角上方"); @@ -232,7 +232,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask }; if (moveX != 0) { - Simulation.SendInputEx.Mouse.MoveMouseBy(moveX, 0); + Simulation.SendInput.Mouse.MoveMouseBy(moveX, 0); Debug.WriteLine("调整方向:" + moveX); } @@ -240,7 +240,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask { if (!wDown) { - Simulation.SendInputEx.Keyboard.KeyDown(User32.VK.VK_W); + Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W); wDown = true; } } @@ -249,7 +249,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask { if (wDown) { - Simulation.SendInputEx.Keyboard.KeyUp(User32.VK.VK_W); + Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W); wDown = false; } // 识别距离 @@ -271,7 +271,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask Logger.LogInformation("未找到追踪点"); } - Simulation.SendInputEx.Mouse.MoveMouseBy(0, 500); // 保证俯视角 + Simulation.SendInput.Mouse.MoveMouseBy(0, 500); // 保证俯视角 Sleep(100); } // }); diff --git a/BetterGenshinImpact/GameTask/AutoSkip/OneKeyExpeditionTask.cs b/BetterGenshinImpact/GameTask/AutoSkip/OneKeyExpeditionTask.cs index 200917eb..b4c37f51 100644 --- a/BetterGenshinImpact/GameTask/AutoSkip/OneKeyExpeditionTask.cs +++ b/BetterGenshinImpact/GameTask/AutoSkip/OneKeyExpeditionTask.cs @@ -42,7 +42,7 @@ public class OneKeyExpeditionTask // 3.退出派遣页面 ESC Sleep(500); - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_ESCAPE); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE); Logger.LogInformation("探索派遣:{Text}", "完成"); }); } diff --git a/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs b/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs index 879bb2ba..eb3ccca2 100644 --- a/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs +++ b/BetterGenshinImpact/GameTask/AutoWood/AutoWoodTask.cs @@ -154,7 +154,7 @@ public class AutoWoodTask } else { - Simulation.SendInputEx.Keyboard.KeyPress(_zKey); + Simulation.SendInput.Keyboard.KeyPress(_zKey); Debug.WriteLine("[AutoWood] Z"); _first = false; } @@ -175,7 +175,7 @@ public class AutoWoodTask #endif } - Simulation.SendInputEx.Keyboard.KeyPress(_zKey); + Simulation.SendInput.Keyboard.KeyPress(_zKey); Debug.WriteLine("[AutoWood] Z"); Sleep(500, taskParam.Cts); }, TimeSpan.FromSeconds(1), 120); @@ -188,7 +188,7 @@ public class AutoWoodTask private void PressEsc(WoodTaskParam taskParam) { SystemControl.Focus(TaskContext.Instance().GameHandle); - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_ESCAPE); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE); Debug.WriteLine("[AutoWood] Esc"); Sleep(800, taskParam.Cts); // 确认在菜单界面 diff --git a/BetterGenshinImpact/GameTask/GameLoading/GameLoading.cs b/BetterGenshinImpact/GameTask/GameLoading/GameLoading.cs index 79e0aaad..927b5505 100644 --- a/BetterGenshinImpact/GameTask/GameLoading/GameLoading.cs +++ b/BetterGenshinImpact/GameTask/GameLoading/GameLoading.cs @@ -75,7 +75,7 @@ public class GameLoadingTrigger : ITaskTrigger // 随便找个相对点击的位置 // _clickOffset?.Click(955, 666); _postMessageSimulator?.LeftButtonClick(); - Simulation.SendInputEx.Mouse.LeftButtonClick(); + Simulation.SendInput.Mouse.LeftButtonClick(); _enterGameClickCount++; } else diff --git a/BetterGenshinImpact/GameTask/Macro/TurnAroundMacro.cs b/BetterGenshinImpact/GameTask/Macro/TurnAroundMacro.cs index 2345f6d4..d932e80d 100644 --- a/BetterGenshinImpact/GameTask/Macro/TurnAroundMacro.cs +++ b/BetterGenshinImpact/GameTask/Macro/TurnAroundMacro.cs @@ -7,7 +7,7 @@ namespace BetterGenshinImpact.GameTask.Macro { public static void Done() { - Simulation.SendInputEx.Mouse.MoveMouseBy(TaskContext.Instance().Config.MacroConfig.RunaroundMouseXInterval, 0); + Simulation.SendInput.Mouse.MoveMouseBy(TaskContext.Instance().Config.MacroConfig.RunaroundMouseXInterval, 0); Thread.Sleep(TaskContext.Instance().Config.MacroConfig.RunaroundInterval); } } diff --git a/BetterGenshinImpact/GameTask/Model/Area/DesktopRegion.cs b/BetterGenshinImpact/GameTask/Model/Area/DesktopRegion.cs index b17407af..1501dff9 100644 --- a/BetterGenshinImpact/GameTask/Model/Area/DesktopRegion.cs +++ b/BetterGenshinImpact/GameTask/Model/Area/DesktopRegion.cs @@ -14,7 +14,7 @@ public class DesktopRegion() : Region(0, 0, PrimaryScreen.WorkingArea.Width, Pri { public void DesktopRegionClick(int x, int y, int w, int h) { - Simulation.SendInputEx.Mouse.MoveMouseTo((x + (w * 1d / 2)) * 65535 / Width, + Simulation.SendInput.Mouse.MoveMouseTo((x + (w * 1d / 2)) * 65535 / Width, (y + (h * 1d / 2)) * 65535 / Height).LeftButtonClick().Sleep(50).LeftButtonUp(); } @@ -25,13 +25,13 @@ public class DesktopRegion() : Region(0, 0, PrimaryScreen.WorkingArea.Width, Pri /// public static void DesktopRegionClick(double cx, double cy) { - Simulation.SendInputEx.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width, + Simulation.SendInput.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width, cy * 65535 * 1d / PrimaryScreen.WorkingArea.Height).LeftButtonDown().Sleep(50).LeftButtonUp(); } public static void DesktopRegionMove(double cx, double cy) { - Simulation.SendInputEx.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width, + Simulation.SendInput.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width, cy * 65535 * 1d / PrimaryScreen.WorkingArea.Height); } diff --git a/BetterGenshinImpact/GameTask/QucikBuy/QuickBuyTask.cs b/BetterGenshinImpact/GameTask/QucikBuy/QuickBuyTask.cs index dd34018d..c036f2ac 100644 --- a/BetterGenshinImpact/GameTask/QucikBuy/QuickBuyTask.cs +++ b/BetterGenshinImpact/GameTask/QucikBuy/QuickBuyTask.cs @@ -30,13 +30,13 @@ public class QuickBuyTask // 选中左边点 742x601 GameCaptureRegion.GameRegion1080PPosMove(742, 601); TaskControl.CheckAndSleep(100); - Simulation.SendInputEx.Mouse.LeftButtonDown(); + Simulation.SendInput.Mouse.LeftButtonDown(); TaskControl.CheckAndSleep(50); // 向右滑动 - Simulation.SendInputEx.Mouse.MoveMouseBy(1000, 0); + Simulation.SendInput.Mouse.MoveMouseBy(1000, 0); TaskControl.CheckAndSleep(200); - Simulation.SendInputEx.Mouse.LeftButtonUp(); + Simulation.SendInput.Mouse.LeftButtonUp(); TaskControl.CheckAndSleep(100); // 点击弹出页的购买/兑换 1100x780 diff --git a/BetterGenshinImpact/GameTask/QuickSereniteaPot/QuickSereniteaPotTask.cs b/BetterGenshinImpact/GameTask/QuickSereniteaPot/QuickSereniteaPotTask.cs index 1de96e9a..cf941245 100644 --- a/BetterGenshinImpact/GameTask/QuickSereniteaPot/QuickSereniteaPotTask.cs +++ b/BetterGenshinImpact/GameTask/QuickSereniteaPot/QuickSereniteaPotTask.cs @@ -60,7 +60,7 @@ public class QuickSereniteaPotTask try { // 打开背包 - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_B); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_B); TaskControl.CheckAndSleep(500); WaitForBagToOpen(); @@ -79,7 +79,7 @@ public class QuickSereniteaPotTask TaskControl.CheckAndSleep(800); // 按F进入 - Simulation.SendInputEx.Keyboard.KeyPress(VK.VK_F); + Simulation.SendInput.Keyboard.KeyPress(VK.VK_F); } catch (Exception e) { diff --git a/BetterGenshinImpact/Helpers/Extensions/ClickExtension.cs b/BetterGenshinImpact/Helpers/Extensions/ClickExtension.cs index 4d7f52f3..f3f3879e 100644 --- a/BetterGenshinImpact/Helpers/Extensions/ClickExtension.cs +++ b/BetterGenshinImpact/Helpers/Extensions/ClickExtension.cs @@ -11,7 +11,7 @@ public static class ClickExtension public static void Click(this Point point) { - Simulation.SendInputEx.Mouse.MoveMouseTo(point.X * 65535 * 1d / PrimaryScreen.WorkingArea.Width, + Simulation.SendInput.Mouse.MoveMouseTo(point.X * 65535 * 1d / PrimaryScreen.WorkingArea.Width, point.Y * 65535 * 1d / PrimaryScreen.WorkingArea.Height).LeftButtonDown().Sleep(50).LeftButtonUp(); } @@ -23,13 +23,13 @@ public static class ClickExtension public static IMouseSimulator Click(double x, double y) { - return Simulation.SendInputEx.Mouse.MoveMouseTo(x * 65535 * 1d / PrimaryScreen.WorkingArea.Width, + return Simulation.SendInput.Mouse.MoveMouseTo(x * 65535 * 1d / PrimaryScreen.WorkingArea.Width, y * 65535 * 1d / PrimaryScreen.WorkingArea.Height).LeftButtonDown().Sleep(50).LeftButtonUp(); } public static IMouseSimulator Move(double x, double y) { - return Simulation.SendInputEx.Mouse.MoveMouseTo(x * 65535 * 1d / PrimaryScreen.WorkingArea.Width, + return Simulation.SendInput.Mouse.MoveMouseTo(x * 65535 * 1d / PrimaryScreen.WorkingArea.Width, y * 65535 * 1d / PrimaryScreen.WorkingArea.Height); } diff --git a/Fischless.KeyboardCapture/KeyboardReader.cs b/Fischless.KeyboardCapture/KeyboardReader.cs index 34674f28..9e545514 100644 --- a/Fischless.KeyboardCapture/KeyboardReader.cs +++ b/Fischless.KeyboardCapture/KeyboardReader.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using Vanara.PInvoke; namespace Fischless.KeyboardCapture; @@ -117,8 +116,8 @@ public class KeyboardReader : IDisposable DateTime now = DateTime.Now; -#if true - //Debug.WriteLine(e.KeyCode); +#if false + Debug.WriteLine(e.KeyCode); #endif KeyboardItem item;