From aadea788537b1d4a31264cfb3591fb6a1fa3bfcc Mon Sep 17 00:00:00 2001 From: MDavid Date: Sat, 14 May 2022 13:56:41 +0200 Subject: [PATCH] Add pixels for X on character --- DD2Switcher/Pixel.cs | 2 +- DD2Switcher/Program.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DD2Switcher/Pixel.cs b/DD2Switcher/Pixel.cs index ea6c3c6..7ad41ac 100644 --- a/DD2Switcher/Pixel.cs +++ b/DD2Switcher/Pixel.cs @@ -20,6 +20,6 @@ public class Pixel { public Boolean ProcessBitmap(Bitmap bmp) { Color tempPixel = bmp.GetPixel(x, y); - return tempPixel.R >= R && tempPixel.B >= B && tempPixel.G >= G; + return tempPixel.R == R && tempPixel.B == B && tempPixel.G == G; } } \ No newline at end of file diff --git a/DD2Switcher/Program.cs b/DD2Switcher/Program.cs index c5ce764..fa073f2 100644 --- a/DD2Switcher/Program.cs +++ b/DD2Switcher/Program.cs @@ -51,7 +51,8 @@ internal static class Program { var i = 0; foreach (var game in games) if (game != activeGame) { - var processAffinty = defaultAffinity >> i; + // var processAffinty = defaultAffinity >> i; + var processAffinty = defaultAffinity; fullAffinity = fullAffinity & ~processAffinty; game.ProcessorAffinity = new IntPtr(processAffinty); i++; @@ -75,6 +76,7 @@ internal static class Program { } private static void SwitchToGame(int index) { + if (index >= games.Length) return; SetForegroundWindow(games[index].MainWindowHandle); activeGame = games[index]; AdjustAffinities(); @@ -109,12 +111,14 @@ internal static class Program { HotKeyManager.RegisterHotKey(Keys.D3, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.D4, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.D5, KeyModifiers.Alt); + HotKeyManager.RegisterHotKey(Keys.D6, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.Q, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.W, KeyModifiers.Alt); HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed; List pixelList = new List(); - pixelList.Add(new Pixel(1062, 885, 240, 240, 240)); + pixelList.Add(new Pixel(108, 108, 0, 0, 0)); + pixelList.Add(new Pixel(1062, 885, 255, 255, 255)); static void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) { switch (e.Key) { @@ -133,6 +137,9 @@ internal static class Program { case Keys.D5: SwitchMainGame(); break; + case Keys.D6: + Environment.Exit(0); + break; case Keys.Q: NerfAll(); break; @@ -155,11 +162,12 @@ internal static class Program { foreach (Pixel p in pixelList) { if (p.ProcessBitmap(screenshot)) { Console.Beep(1500, 850); + break; } } - Thread.Sleep(1000); + Thread.Sleep(250); } - Thread.Sleep(1000); + Thread.Sleep(250); } } } \ No newline at end of file