From be2c6f7829faa557c13e8c84a29d39a4e77a477b Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 4 Jan 2025 12:17:14 +0100 Subject: [PATCH] Add support for 19 processes --- DD2Switcher/Program.cs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/DD2Switcher/Program.cs b/DD2Switcher/Program.cs index 8b22a8d..e39adf2 100644 --- a/DD2Switcher/Program.cs +++ b/DD2Switcher/Program.cs @@ -7,7 +7,7 @@ using System.Windows.Forms; namespace DD2Switcher; internal static class Program { - private static int NumProc = 10; + private static int NumProc = 19; private static Process[] windows = new Process[NumProc]; private static int ActiveIndex = -1; @@ -208,12 +208,18 @@ internal static class Program { Process.GetCurrentProcess().Kill(); } - for (int i = 0; i < NumProc; i++) { - windows[i] = null; + // Register main number keys (0-9) + for (int i = 0; i < 10; i++) { HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt | KeyModifiers.Shift); } + // Register numpad keys (1-9) + for (int i = 0; i < 9; i++) { + HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt); + HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt | KeyModifiers.Shift); + } + HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt); HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed; @@ -223,15 +229,25 @@ internal static class Program { return; } + int index; + if (e.Key >= Keys.D0 && e.Key <= Keys.D9) { + index = e.Key - Keys.D0; + } + else if (e.Key >= Keys.NumPad1 && e.Key <= Keys.NumPad9) { + index = 10 + (e.Key - Keys.NumPad1); + } + else { + return; + } + if (e.Modifiers == KeyModifiers.Alt) { - TabTo(e.Key - Keys.D0); + TabTo(index); } else if (e.Modifiers == (KeyModifiers.Alt | KeyModifiers.Shift)) { - Swap(e.Key - Keys.D0); + Swap(index); } } - Console.CancelKeyPress += (sender, e) => { Process.GetCurrentProcess().Kill(); }; while (true) System.Threading.Thread.Sleep(100000);