Skip to content

Commit

Permalink
- Aimmy 1.4.6 Update -
Browse files Browse the repository at this point in the history
Changelog:
- Reverted from using the input driver as many users were having issues with it. All input is back on Mouse_events.
- We are looking at doing better configs with the aim to allow users to adjust it even further, allowing for further humanizing.
- Merged pull from liveslice "Allow minimizing from the taskbar".
- Merged pull from liveslice "Fix a crash and small issues with the overlay window".
- Fixed Button Styling (Broken due to MaterialDesignColors update)
- Added Downloadable Configs System
- Added Dedicated Config Saving System
- Fixed Auto-Save Config Saving
- Added auto model config text if model is loaded
- Removed some code that is no longer used
- Made random jitter slightly stronger
- Bumped version to 1.4.6
  • Loading branch information
Babyhamsta authored and Babyhamsta committed Dec 15, 2023
1 parent 25af9ab commit daf1bd6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 124 deletions.
1 change: 0 additions & 1 deletion AimmyWPF/AimmyWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="InputInterceptor-Forked" Version="1.0.0" />
<PackageReference Include="KdTree" Version="1.4.1" />
<PackageReference Include="MaterialDesignColors" Version="3.0.0-ci472" />
<PackageReference Include="MaterialDesignThemes" Version="5.0.0-ci472" />
Expand Down
141 changes: 22 additions & 119 deletions AimmyWPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
using AimmyAimbot;
using Class;
using Newtonsoft.Json;
using InputInterceptorNS;
using System.Reflection;
using System.Diagnostics;
using System.Collections;
using Accord.Math;
using SecondaryWindows;
using System.Runtime.InteropServices;

namespace AimmyWPF
{
Expand All @@ -28,7 +26,6 @@ public partial class MainWindow : Window
private OverlayWindow FOVOverlay;
private FileSystemWatcher fileWatcher;
private FileSystemWatcher ConfigfileWatcher;
private MouseHook mouseHook;

private string lastLoadedModel = "N/A";
private string lastLoadedConfig = "N/A";
Expand Down Expand Up @@ -93,11 +90,6 @@ private enum MenuPosition
Thickness WinVeryRight = new Thickness(1120, 0, -1120, 0);
Thickness WinTooRight = new Thickness(1680, 0, -1680, 0);

private void mouse_callback(ref MouseStroke mouseStroke)
{
Console.WriteLine($"{mouseStroke.X} {mouseStroke.Y} {mouseStroke.Flags} {mouseStroke.State} {mouseStroke.Information}");
}

private bool StartedLoad = false;
public MainWindow()
{
Expand All @@ -117,49 +109,6 @@ public MainWindow()
Application.Current.Shutdown();
}

// Setup Mouse Interceptor
if (!InputInterceptor.CheckDriverInstalled())
{
if (InputInterceptor.CheckAdministratorRights())
{
try
{
InputInterceptor.InstallDriver();
}
catch (Exception ex)
{
MessageBox.Show($"There was an error installing the input driver, please restart the application and try again or reboot and try again. Error: {ex}", "Input Error");
Application.Current.Shutdown();
}
}
else
{
MessageBox.Show("Please run Aimmy as admin once so the InputInterceptor driver can install.", "Input Error");
Application.Current.Shutdown();
}
}
else
{
try
{
MouseFilter filter = MouseFilter.All;

if (InputInterceptor.Initialize() && mouseHook == null)
{
mouseHook = new MouseHook(filter, mouse_callback);
}
else
{
throw new Exception("InputInterceptor failed to initalize.");
}
}
catch (Exception ex)
{
MessageBox.Show($"Unable to create MouseHook, please try rebooting and then running Aimmy again.\n\nError: {ex}", "Input Error");
Application.Current.Shutdown();
}
}

// Check for required folders
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string[] dirs = { "bin", "bin/models", "bin/images", "bin/configs" };
Expand Down Expand Up @@ -204,16 +153,6 @@ public MainWindow()
this.Topmost = setting.Value;
}
}

// I think we should remove this - Nori

//// Assuming you also want to load "Suggested_Model" and handle it
//var specialConfig = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
//if (specialConfig != null && specialConfig.ContainsKey("Suggested_Model"))
//{
// MessageBox.Show("The creator of this model suggests you use this model:\n" +
// specialConfig["Suggested_Model"], "Suggested Model - Aimmy");
//}
}

// Load UI
Expand Down Expand Up @@ -275,6 +214,20 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
}

#region Mouse Movement / Clicking Handler
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetCursorPos(out POINT lpPoint);

[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
}

private static Random MouseRandom = new Random();

private static Point CubicBezier(Point start, Point end, Point control1, Point control2, double t)
Expand All @@ -299,9 +252,9 @@ private async Task DoTriggerClick()

if (TimeSinceLastClick >= Trigger_Delay_Milliseconds || LastClickTime == DateTime.MinValue)
{
mouseHook.SimulateLeftButtonDown();
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
await Task.Delay(20);
mouseHook.SimulateLeftButtonUp();
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
LastClickTime = DateTime.Now;
}

Expand All @@ -319,8 +272,8 @@ private void MoveCrosshair(int detectedX, int detectedY)
int targetY = detectedY - halfScreenHeight;

// Introduce random jitter
int jitterX = MouseRandom.Next(-2, 3);
int jitterY = MouseRandom.Next(-2, 3);
int jitterX = MouseRandom.Next(-4, 4);
int jitterY = MouseRandom.Next(-4, 4);

targetX += jitterX;
targetY += jitterY;
Expand All @@ -334,7 +287,7 @@ private void MoveCrosshair(int detectedX, int detectedY)
// Calculate new position along the Bezier curve
Point newPosition = CubicBezier(start, end, control1, control2, 1 - Alpha);

mouseHook.MoveCursorBy((int)newPosition.X, (int)newPosition.Y);
mouse_event(MOUSEEVENTF_MOVE, (uint)newPosition.X, (uint)newPosition.Y, 0, 0);

if (toggleState["TriggerBot"])
{
Expand Down Expand Up @@ -776,31 +729,6 @@ void LoadConfig(string path)
{
if (ConfigSelectorListBox.SelectedItem != null && lastLoadedModel != "N/A")
{
#region Consider Deleting - Nori
//dynamic AimmyJSON = JsonConvert.DeserializeObject(File.ReadAllText(path));

//MessageBox.Show("The creator of this model suggests you use this model:" +
// "\n" +
// AimmyJSON.Suggested_Model, "Suggested Model - Aimmy");

//aimmySettings["FOV_Size"] = (int)AimmyJSON.FOV_Size;
//FOVOverlay.FovSize = (int)aimmySettings["FOV_Size"];
//_onnxModel.FovSize = (int)aimmySettings["FOV_Size"];

//aimmySettings["Mouse_Sens"] = AimmyJSON.Mouse_Sensitivity;
//aimmySettings["Y_Offset"] = AimmyJSON.Y_Offset;
//aimmySettings["X_Offset"] = AimmyJSON.X_Offset;
//aimmySettings["Trigger_Delay"] = AimmyJSON.Auto_Trigger_Delay;

//aimmySettings["AI_Min_Conf"] = AimmyJSON.AI_Minimum_Confidence;
//_onnxModel.ConfidenceThreshold = (float)(aimmySettings["AI_Min_Conf"] / 100.0f);

//lastLoadedConfig = ConfigSelectorListBox.SelectedItem.ToString();

//// Reload the UI
//ReloadMenu();

#endregion
string json = File.ReadAllText(path);

// Deserialize JSON directly into a dictionary
Expand Down Expand Up @@ -981,33 +909,10 @@ void LoadSettingsMenu()

SaveConfigSystem.Reader.Click += (s, e) =>
{
new ConfigSaver(aimmySettings).ShowDialog();
new ConfigSaver(aimmySettings, lastLoadedModel).ShowDialog();
};

SettingsScroller.Children.Add(SaveConfigSystem);

AButton UninstallDriver = new AButton(this, "Uninstall Input Driver",
"This will auto uninstall the input driver used to prevent detections on Aimmy. Note: If you reopen the driver version of Aimmy it will auto reinstall the driver.");

UninstallDriver.Reader.Click += (s, e) =>
{
try
{
UninstallDriver.IsEnabled = false;
UninstallDriver.Content = "Uninstalling...";
InputInterceptor.UninstallDriver();
MessageBox.Show("Driver uninstalled, Aimmy will now close, please reboot your computer to complete the uninstall.");
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show($"Unable to uninstall driver: {ex}");
UninstallDriver.IsEnabled = true;
}

};

SettingsScroller.Children.Add(UninstallDriver);
}

#region Window Controls
Expand Down Expand Up @@ -1053,9 +958,7 @@ private void Window_Closing(object sender, CancelEventArgs e)
}
SavedData = true;

// Unhook keybind/mousehook
mouseHook.Dispose();
InputInterceptor.Dispose();
// Unhook keybind hooker
bindingManager.StopListening();
FOVOverlay.Close();

Expand Down
10 changes: 7 additions & 3 deletions AimmyWPF/SecondaryWindows/ConfigSaver.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using InputInterceptorNS;
using Newtonsoft.Json;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -27,11 +26,16 @@ public partial class ConfigSaver : Window

string ExtraStrings = string.Empty;

public ConfigSaver(Dictionary<string, dynamic> CurrentAimmySettings)
public ConfigSaver(Dictionary<string, dynamic> CurrentAimmySettings, string lastLoadedModel)
{
InitializeComponent();
aimmySettings = CurrentAimmySettings;

if (lastLoadedModel != "N/A")
{
RecommendedModelNameTextBox.Text = lastLoadedModel.Split(".")[0];
}

}

void WriteJSON()
Expand Down
2 changes: 1 addition & 1 deletion AimmyWPF/UserController/AInfoSection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
Foreground="White" />
<Label x:Name="VersionNumber"
Foreground="White"
Content="v1.4.5"
Content="v1.4.6"
VerticalContentAlignment="Center"
Padding="5,0,0,0"
FontSize="20"
Expand Down

0 comments on commit daf1bd6

Please sign in to comment.