diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..353054c --- /dev/null +++ b/.gitignore @@ -0,0 +1,260 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/FutureNNAimbot.sln b/FutureNNAimbot.sln new file mode 100644 index 0000000..f955b98 --- /dev/null +++ b/FutureNNAimbot.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FutureNNAimbot", "FutureNNAimbot\FutureNNAimbot.csproj", "{63BDD8BB-BE91-45CD-A998-34A8912A69E6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63BDD8BB-BE91-45CD-A998-34A8912A69E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63BDD8BB-BE91-45CD-A998-34A8912A69E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63BDD8BB-BE91-45CD-A998-34A8912A69E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63BDD8BB-BE91-45CD-A998-34A8912A69E6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E02B1089-2AC8-43E6-8963-20B6FDDEBECF} + EndGlobalSection +EndGlobal diff --git a/FutureNNAimbot/App.config b/FutureNNAimbot/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/FutureNNAimbot/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/FutureNNAimbot/FutureNNAimbot.csproj b/FutureNNAimbot/FutureNNAimbot.csproj new file mode 100644 index 0000000..22310ce --- /dev/null +++ b/FutureNNAimbot/FutureNNAimbot.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {63BDD8BB-BE91-45CD-A998-34A8912A69E6} + Exe + FutureNNAimbot + FutureNNAimbot + v4.6.1 + 512 + true + true + + + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + ..\packages\Alturos.Yolo.2.4.1\lib\net461\Alturos.Yolo.dll + + + ..\packages\GameOverlay.Net.4.0.1\lib\GameOverlay.dll + + + ..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll + + + ..\packages\SharpDX.Direct2D1.4.2.0\lib\net45\SharpDX.Direct2D1.dll + + + ..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll + + + + + + + + + + + + + + + + + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/FutureNNAimbot/Program.cs b/FutureNNAimbot/Program.cs new file mode 100644 index 0000000..69a0a2e --- /dev/null +++ b/FutureNNAimbot/Program.cs @@ -0,0 +1,428 @@ +using Alturos.Yolo; +using System; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using GameOverlay.Drawing; +using GameOverlay.Windows; +using System.Diagnostics; +using System.Windows.Forms; +using System.Runtime.Serialization.Json; +using System.Runtime.Serialization; + +namespace FutureNNAimbot +{ + [DataContract] + public class Settings + { + [DataMember] + public int SizeX { get; set; } + [DataMember] + public int SizeY { get; set; } + [DataMember] + public string Game { get; set; } + [DataMember] + public bool SimpleRCS { get; set; } + [DataMember] + public Keys ShootKey { get; set; } + [DataMember] + public Keys TrainModeKey { get; set; } + + public Settings(int SizeX, int SizeY,string Game,bool SimpleRCS, Keys ShootKey, Keys TrainModeKey) + { + this.SizeX = SizeX; + this.SizeY = SizeY; + this.Game = Game; + this.SimpleRCS = SimpleRCS; + this.ShootKey = ShootKey; + this.TrainModeKey = TrainModeKey; + + } + } + + class Program + { + + private class GDI32 + { + + public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter + [DllImport("gdi32.dll")] + public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, + int nWidth, int nHeight, IntPtr hObjectSource, + int nXSrc, int nYSrc, int dwRop); + [DllImport("gdi32.dll")] + public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, + int nHeight); + [DllImport("gdi32.dll")] + public static extern IntPtr CreateCompatibleDC(IntPtr hDC); + [DllImport("gdi32.dll")] + public static extern bool DeleteDC(IntPtr hDC); + [DllImport("gdi32.dll")] + public static extern bool DeleteObject(IntPtr hObject); + [DllImport("gdi32.dll")] + public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); + } + + class User32 + { + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + } + [DllImport("user32.dll")] + public static extern IntPtr GetDesktopWindow(); + [DllImport("user32.dll")] + public static extern IntPtr GetWindowDC(IntPtr hWnd); + [DllImport("user32.dll")] + public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC); + [DllImport("user32.dll")] + public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect); + [DllImport("user32.dll")] + public static extern short GetKeyState(int vKey); + [DllImport("User32.dll")] + public static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); + [DllImport("User32.Dll")] + public static extern long SetCursorPos(int x, int y); + [DllImport("user32.dll")] + public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, + UIntPtr dwExtraInfo); + + } + [DllImport("kernel32.dll")] + public static extern void ExitProcess([In] uint uExitCode); + + static System.Drawing.Point size = new System.Drawing.Point(320, 320); + + static void Main(string[] args) + { + // Read settings + DataContractJsonSerializer Settings = new DataContractJsonSerializer(typeof(Settings[])); + Settings[] settings = null; + //Settings settings = new Settings(320, 320, "csgo", true ,Keys.RButton,Keys.Insert); + //using (FileStream fs = new FileStream("config.json", FileMode.OpenOrCreate)) + //{ + // Settings.WriteObject(fs, new Settings[1] { settings }); + //} + using (FileStream fs = new FileStream("config.json", FileMode.OpenOrCreate)) + { + settings = (Settings[])Settings.ReadObject(fs); + } + size.X = settings[0].SizeX; + size.Y = settings[0].SizeY; + string game = settings[0].Game; + bool SimpleRCS = settings[0].SimpleRCS; + Keys ShootKey = settings[0].ShootKey; + Keys TrainModeKey = settings[0].TrainModeKey; + + + //Vars + int i = 0; + int selectedObject = 0; + double shoots = 0; + string[] objects = null; + System.Drawing.Point coordinates; + OverlayWindow _window; + GameOverlay.Drawing.Graphics _graphics; + bool trainingMode = false; + YoloWrapper yoloWrapper = null; + //Check compatibility + if (Process.GetProcessesByName(game).Count() == 0) + { + MessageBox.Show($"Looks like you don't launch game {game}..."); + Process.GetCurrentProcess().Kill(); + } + + if (File.Exists($"trainfiles/{game}.cfg") && File.Exists($"trainfiles/{game}.weights") && File.Exists($"trainfiles/{game}.names")) + { + yoloWrapper = new YoloWrapper($"trainfiles/{game}.cfg", $"trainfiles/{game}.weights", $"trainfiles/{game}.names"); + Console.Clear(); + if (yoloWrapper.EnvironmentReport.CudaExists == false) + { + Console.WriteLine("Install CUDA 10"); + Process.GetCurrentProcess().Kill(); + } + if (yoloWrapper.EnvironmentReport.CudnnExists == false) + { + Console.WriteLine("Cudnn doesn't exists"); + Process.GetCurrentProcess().Kill(); + } + if (yoloWrapper.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists == false) + { + Console.WriteLine("Install Microsoft Visual C++ 2017 Redistributable"); + Process.GetCurrentProcess().Kill(); + } + if (yoloWrapper.DetectionSystem.ToString() != "GPU") + { + MessageBox.Show("No GPU card detected. Exit..."); + Process.GetCurrentProcess().Kill(); + } + objects = File.ReadAllLines($"trainfiles/{game}.names"); + } + else + { + trainingMode = true; + MessageBox.Show($"Looks like you haven't configured configs for game {game}... Let's go to train Neural Network! :)\n Prepairing files for training...."); + + Console.Write("How much objects we will be analyse and train for detect? Write objects name via separator ',' without space : "); + objects = Console.ReadLine().Split(','); + + } + + + PrepareFiles(game); + + + //Make transparent window for drawing + _window = new OverlayWindow(0, 0, size.X, size.Y) + { + IsTopmost = true, + IsVisible = true + }; + _graphics = new GameOverlay.Drawing.Graphics() + { + MeasureFPS = true, + Height = _window.Height, + PerPrimitiveAntiAliasing = true, + TextAntiAliasing = true, + UseMultiThreadedFactories = false, + VSync = true, + Width = _window.Width, + WindowHandle = IntPtr.Zero + }; + + _window.CreateWindow(); + + _graphics.WindowHandle = _window.Handle; + _graphics.Setup(); + + + GameOverlay.Drawing.Graphics gfx = _graphics; + + System.Drawing.Rectangle trainBox = new System.Drawing.Rectangle(0, 0, size.X / 2, size.Y / 2); + + + + + + while (true) + { + + coordinates = Cursor.Position; + Bitmap bitmap = new Bitmap(CaptureWindow(game), size.X, size.Y); + + + trainBox.X = size.X / 2 - trainBox.Width / 2; + trainBox.Y = size.Y / 2 - trainBox.Height / 2; + if (User32.GetAsyncKeyState(TrainModeKey) == -32767) + { + if (yoloWrapper != null) + { + + objects = File.ReadAllLines($"trainfiles/{game}.names"); + trainingMode = trainingMode == true ? false : true; + } + } + + if (User32.GetAsyncKeyState(Keys.Left) == -32767) + { + trainBox.Width -= 1; + } + if (User32.GetAsyncKeyState(Keys.Down) == -32767) + { + trainBox.Height += 1; + } + + if (User32.GetAsyncKeyState(Keys.Right) == -32767) + { + trainBox.Width += 1; + } + if (User32.GetAsyncKeyState(Keys.Up) == -32767) + { + trainBox.Height -= 1; + } + _window.X = coordinates.X - size.X / 2; + _window.Y = coordinates.Y - size.Y / 2; + gfx.BeginScene(); + gfx.ClearScene(); + + gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Green), 0, 0, size.X, size.Y, 2); + + + + if (trainingMode) + { + + float relative_center_x = (float)(trainBox.X + trainBox.Width / 2) / size.X; + float relative_center_y = (float)(trainBox.Y + trainBox.Height / 2) / size.Y; + float relative_width = (float)trainBox.Width / size.X; + float relative_height = (float)trainBox.Height / size.Y; + gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 14), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(0, 0), "Training mode. Object " + objects[selectedObject]); + gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), GameOverlay.Drawing.Rectangle.Create(trainBox.X, trainBox.Y, trainBox.Width, trainBox.Height), 1); + + if (User32.GetAsyncKeyState(Keys.PageUp) == -32767) + { + selectedObject = selectedObject + 1 == objects.Count() ? 0 : selectedObject + 1; + } + if (User32.GetAsyncKeyState(Keys.PageDown) == -32767) + { + selectedObject = selectedObject == 0 ? objects.Count() - 1 : selectedObject - 1; + } + + if (User32.GetAsyncKeyState(Keys.Home) == -32767) + { + bitmap.Save($"darknet/data/img/{game}{i.ToString()}.png", System.Drawing.Imaging.ImageFormat.Png); + File.WriteAllText($"darknet/data/img/{game}{i.ToString()}.txt", string.Format("{0} {1} {2} {3} {4}", selectedObject, relative_center_x, relative_center_y, relative_width, relative_height).Replace(",", ".")); + File.WriteAllText($"darknet/data/{game}.txt", File.ReadAllText($"darknet/data/{game}.txt") + $"data/img/{game}{i.ToString()}.png\r\n"); + i++; + Console.Beep(); + } + if (User32.GetAsyncKeyState(Keys.End) == -32767) + { + Console.WriteLine("Okey, we have pictures for training. Let's train Neural Network...."); + File.WriteAllText($"darknet/{game}.cfg", File.ReadAllText($"darknet/{game}.cfg").Replace("NUMBER", objects.Count().ToString()).Replace("FILTERNUM", ((objects.Count() + 5) * 3).ToString())); + File.WriteAllText($"darknet/data/{game}.data", File.ReadAllText($"darknet/data/{game}.data").Replace("NUMBER", objects.Count().ToString()).Replace("GAME", game)); + File.WriteAllText($"darknet/{game}.cmd", File.ReadAllText($"darknet/{game}.cmd").Replace("GAME", game)); + File.WriteAllText($"darknet/{game}_trainmore.cmd", File.ReadAllText($"darknet/{game}_trainmore.cmd").Replace("GAME", game)); + File.WriteAllText($"darknet/data/{game}.names", string.Join("\n", objects)); + if(File.Exists($"trainfiles/{game}.weights")) + { + File.Copy($"trainfiles/{game}.weights", $"darknet/{game}.weights"); + Process.Start("cmd", @"/C cd " + Application.StartupPath + $"/darknet/ & {game}_trainmore.cmd"); + } + else Process.Start("cmd", @"/C cd " + Application.StartupPath + $"/darknet/ & {game}.cmd"); + + Console.WriteLine("Then you finished training write \"done\" in this console!"); + + while (true) + { + if (Console.ReadLine() == "done") + { + + File.Copy($"darknet/data/backup/{game}_last.weights", $"trainfiles/{game}.weights",true); + File.Copy($"darknet/data/{game}.names", $"trainfiles/{game}.names", true); + File.Copy($"darknet/{game}.cfg", $"trainfiles/{game}.cfg", true); + yoloWrapper = new YoloWrapper($"trainfiles/{game}.cfg", $"trainfiles/{game}.weights", $"trainfiles/{game}.names"); + trainingMode = false; + break; + + } + else Console.WriteLine("Then you finished training write \"done\" in this console!"); + } + Console.WriteLine("Okey! Training finished :) Let's check detection in the game!"); + } + + } + else + { + if (User32.GetAsyncKeyState(Keys.PageUp) == -32767) + { + selectedObject = selectedObject + 1 == objects.Count() ? 0 : selectedObject + 1; + } + if (User32.GetAsyncKeyState(Keys.PageDown) == -32767) + { + selectedObject = selectedObject == 0 ? objects.Count() - 1 : selectedObject - 1; + } + gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 14), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(0, 0), "Object " + objects[selectedObject]); + + using (MemoryStream ms = new MemoryStream()) + { + bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + IEnumerable items = yoloWrapper.Detect(ms.ToArray()); + if (SimpleRCS) + if (User32.GetAsyncKeyState(ShootKey) == 0) shoots = 0; + + if (items.Count() > 0) + { + + foreach (var item in items) + { + if (item.Confidence > (double)0.4) + { + + gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 12), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(item.X + item.Width, item.Y + item.Width), $"{item.Type} {item.Confidence.ToString()}"); + if (item.Type == objects[selectedObject]) + { + gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), GameOverlay.Drawing.Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); + gfx.DrawCrosshair(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), item.X + item.Width / 2, item.Y + item.Height / 7 + Convert.ToInt32(1 * shoots), 2, 2, CrosshairStyle.Cross); + + if (User32.GetAsyncKeyState(ShootKey) != 0) + { + Alturos.Yolo.Model.YoloItem nearestEnemy = items.Where(x => x.Type == objects[selectedObject]).OrderByDescending(x => x.Width * x.Height).First(); + if ((nearestEnemy.X - size.X / 2) + (nearestEnemy.Width / 2) < 320 && nearestEnemy.Y - size.Y / 2 + item.Height / 7 + 1 * shoots < 320) + { + User32.mouse_event(0x01, Convert.ToInt32((nearestEnemy.X - size.X / 2) + (nearestEnemy.Width / 2)), Convert.ToInt32(nearestEnemy.Y - size.Y / 2 + item.Height / 7 + 1 * shoots), 0, (UIntPtr)0); + User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); + User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); + if (SimpleRCS) shoots += 1; + } + } + } + else + { + gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Green), GameOverlay.Drawing.Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); + } + } + + } + } + else { if (SimpleRCS) shoots = 0; } + } + + } + gfx.FillRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), GameOverlay.Drawing.Rectangle.Create(size.X / 2, size.Y / 2, 4, 4)); + + gfx.EndScene(); + } + } + //Get screenshot on the center of game + public static System.Drawing.Image CaptureWindow(string name) + { + if (Process.GetProcessesByName(name).Count() == 0) + { + MessageBox.Show($"Looks like you close the game {name}..."); + Process.GetCurrentProcess().Kill(); + } + IntPtr handle = Process.GetProcessesByName(name)[0].MainWindowHandle; + IntPtr hdcSrc = User32.GetWindowDC(handle); + User32.RECT windowRect = new User32.RECT(); + User32.GetWindowRect(handle, ref windowRect); + int width = windowRect.right - windowRect.left; + int height = windowRect.bottom - windowRect.top; + IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc); + IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, size.X, size.Y); + IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap); + GDI32.BitBlt(hdcDest, 0, 0, size.X, size.Y, hdcSrc, width / 2 - size.X / 2, height / 2 - size.Y / 2, GDI32.SRCCOPY); + GDI32.SelectObject(hdcDest, hOld); + GDI32.DeleteDC(hdcDest); + User32.ReleaseDC(handle, hdcSrc); + System.Drawing.Image img = System.Drawing.Image.FromHbitmap(hBitmap); + GDI32.DeleteObject(hBitmap); + return img; + } + public static void PrepareFiles(string game) + { + + File.Copy("defaultfiles/default_trainmore.cmd", $"darknet/{game}_trainmore.cmd", true); + if (File.Exists($"trainfiles/{game}.cfg")) File.Copy($"trainfiles/{game}.cfg", $"darknet/{game}.cfg", true); + else File.Copy("defaultfiles/default.cfg", $"darknet/{game}.cfg", true); + + File.Copy("defaultfiles/default.conv.15", $"darknet/{game}.conv.15", true); + File.Copy("defaultfiles/default.data", $"darknet/data/{game}.data", true); + + if (File.Exists($"trainfiles/{game}.names")) File.Copy($"trainfiles/{game}.names", $"darknet/{game}.names", true); + else File.Copy("defaultfiles/default.names", $"darknet/data/{game}.names", true); + + File.Copy("defaultfiles/default.txt", $"darknet/data/{game}.txt", true); + File.Copy("defaultfiles/default.cmd", $"darknet/{game}.cmd", true); + } + + } +} diff --git a/FutureNNAimbot/Properties/AssemblyInfo.cs b/FutureNNAimbot/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce537ef --- /dev/null +++ b/FutureNNAimbot/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("FutureNNAimbot")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FutureNNAimbot")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("63bdd8bb-be91-45cd-a998-34a8912a69e6")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номер сборки и номер редакции по умолчанию. +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/FutureNNAimbot/packages.config b/FutureNNAimbot/packages.config new file mode 100644 index 0000000..1bc1c71 --- /dev/null +++ b/FutureNNAimbot/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file