From c4075c48948c0786aeb66623e8d32d5ac8128cba Mon Sep 17 00:00:00 2001 From: whoswhip Date: Sat, 19 Jul 2025 07:56:24 -0400 Subject: [PATCH] feat: replace POINT struct and add trigger bot feature Refactor `InputManager.cs` to use the built-in `Point` struct for improved readability. Introduced a new `ClickMouse` method to manage mouse click events based on the current position and trigger bot functionality. Updated `Renderer.cs` to add a checkbox for enabling/disabling the trigger bot in the user interface. --- Spectrum/InputManager.cs | 39 ++++++++++++++++++++++++++++++--------- Spectrum/Renderer.cs | 5 +++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Spectrum/InputManager.cs b/Spectrum/InputManager.cs index e48a68f..8577174 100644 --- a/Spectrum/InputManager.cs +++ b/Spectrum/InputManager.cs @@ -8,14 +8,10 @@ namespace Spectrum private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo); [DllImport("user32.dll")] - private static extern bool GetCursorPos(out POINT lpPoint); + private static extern bool GetCursorPos(out Point lpPoint); private static ConfigManager mainConfig = Program.mainConfig; + private static Point lastDetection = new Point(); - private struct POINT - { - public int X; - public int Y; - } // AIMMY V2 CODE - https://github.com/Babyhamsta/Aimmy/blob/2e906552673e359ded90383c5e97d79c8f38a2f2/Aimmy2/InputLogic/MouseManager.cs#L34-L50 private static Point CubicBezier(Point start, Point end, Point control1, Point control2, double t) { @@ -73,7 +69,7 @@ namespace Spectrum public static void MoveMouse(Point target) { - POINT reference = new POINT(); + Point reference = new Point(); if (mainConfig.Data.ClosestToMouse) { GetCursorPos(out reference); @@ -85,7 +81,7 @@ namespace Spectrum reference.Y = SystemHelper.GetPrimaryScreenSize().Height / 2; } - + lastDetection = target; Point start = new Point(reference.X, reference.Y); Point end = new Point(target.X, target.Y); @@ -111,8 +107,33 @@ namespace Spectrum if (deltaX > mainConfig.Data.ImageWidth || deltaX < -mainConfig.Data.ImageWidth || deltaY > mainConfig.Data.ImageHeight || deltaY < -mainConfig.Data.ImageHeight) return; - mouse_event(0x0001, (uint)(deltaX), (uint)(deltaY), 0, 0); + ClickMouse(); + } + + public static void ClickMouse() + { + if (!mainConfig.Data.TriggerBot) + return; + + var currentMousePosition = new Point(); + if (mainConfig.Data.ClosestToMouse) + { + GetCursorPos(out currentMousePosition); + } + else + { + // center of the screen + currentMousePosition.X = SystemHelper.GetPrimaryScreenSize().Width / 2; + currentMousePosition.Y = SystemHelper.GetPrimaryScreenSize().Height / 2; + } + + if (Math.Abs(currentMousePosition.X - lastDetection.X) < 25 && Math.Abs(currentMousePosition.Y - lastDetection.Y) < 25) + { + mouse_event(0x0002, 0, 0, 0, 0); + Thread.Sleep(5); + mouse_event(0x0004, 0, 0, 0, 0); + } } [DllImport("user32.dll")] private static extern short GetAsyncKeyState(int vKey); diff --git a/Spectrum/Renderer.cs b/Spectrum/Renderer.cs index e7a4efd..cf2db6e 100644 --- a/Spectrum/Renderer.cs +++ b/Spectrum/Renderer.cs @@ -98,6 +98,11 @@ namespace Spectrum { mainConfig.Data.ClosestToMouse = closestToMouse; } + bool triggerBot = mainConfig.Data.TriggerBot; + if (ImGui.Checkbox("Trigger Bot", ref triggerBot)) + { + mainConfig.Data.TriggerBot = triggerBot; + } float sensitivity = (float)mainConfig.Data.Sensitivity; if (ImGui.SliderFloat("Sensitivity", ref sensitivity, 0.1f, 2.0f, "%.1f"))