mirror of
https://github.com/whoswhip/Spectrum.git
synced 2026-12-06 01:28:42 +00:00
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.
This commit is contained in:
@@ -8,14 +8,10 @@ namespace Spectrum
|
|||||||
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
|
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool GetCursorPos(out POINT lpPoint);
|
private static extern bool GetCursorPos(out Point lpPoint);
|
||||||
private static ConfigManager<ConfigData> mainConfig = Program.mainConfig;
|
private static ConfigManager<ConfigData> 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
|
// 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)
|
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)
|
public static void MoveMouse(Point target)
|
||||||
{
|
{
|
||||||
POINT reference = new POINT();
|
Point reference = new Point();
|
||||||
if (mainConfig.Data.ClosestToMouse)
|
if (mainConfig.Data.ClosestToMouse)
|
||||||
{
|
{
|
||||||
GetCursorPos(out reference);
|
GetCursorPos(out reference);
|
||||||
@@ -85,7 +81,7 @@ namespace Spectrum
|
|||||||
reference.Y = SystemHelper.GetPrimaryScreenSize().Height / 2;
|
reference.Y = SystemHelper.GetPrimaryScreenSize().Height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastDetection = target;
|
||||||
|
|
||||||
Point start = new Point(reference.X, reference.Y);
|
Point start = new Point(reference.X, reference.Y);
|
||||||
Point end = new Point(target.X, target.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)
|
if (deltaX > mainConfig.Data.ImageWidth || deltaX < -mainConfig.Data.ImageWidth || deltaY > mainConfig.Data.ImageHeight || deltaY < -mainConfig.Data.ImageHeight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
mouse_event(0x0001, (uint)(deltaX), (uint)(deltaY), 0, 0);
|
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")]
|
[DllImport("user32.dll")]
|
||||||
private static extern short GetAsyncKeyState(int vKey);
|
private static extern short GetAsyncKeyState(int vKey);
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ namespace Spectrum
|
|||||||
{
|
{
|
||||||
mainConfig.Data.ClosestToMouse = closestToMouse;
|
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;
|
float sensitivity = (float)mainConfig.Data.Sensitivity;
|
||||||
if (ImGui.SliderFloat("Sensitivity", ref sensitivity, 0.1f, 2.0f, "%.1f"))
|
if (ImGui.SliderFloat("Sensitivity", ref sensitivity, 0.1f, 2.0f, "%.1f"))
|
||||||
|
|||||||
Reference in New Issue
Block a user