From 9de3ae43d58eb42954adcd9d2604bf831994511c Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 2 Jul 2025 09:05:26 +0200 Subject: [PATCH] Improve code formatting and comment out TrackWows method for future reference --- DD2Switcher/Program.cs | 45 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/DD2Switcher/Program.cs b/DD2Switcher/Program.cs index 6918f22..cb9e605 100644 --- a/DD2Switcher/Program.cs +++ b/DD2Switcher/Program.cs @@ -28,7 +28,8 @@ internal static class Program { static extern bool AllocConsole(); [DllImport("user32.dll")] - private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo); + private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, + int dwExtraInfo); private static void CleanWindows() { for (int i = 0; i < NumProc; i++) { @@ -145,21 +146,22 @@ internal static class Program { // Add the new process at the first null slot windows[firstNullIndex] = process; - Console.WriteLine($"Added {process.ProcessName} to tracked windows at index {firstNullIndex}"); + Console.WriteLine( + $"Added {process.ProcessName} to tracked windows at index {firstNullIndex}"); } - private static void TrackWows() { - CleanWindows(); - var processes = Process.GetProcesses().OrderBy(p => p.Id).ToList(); - foreach (var process in processes) { - if (process.ProcessName == "UWow-64") { - Console.WriteLine($"Found UWow-64 at pid {process.Id}"); - if (ProcessTracked(process.Id)) - continue; - Track(process); - } - } - } + // private static void TrackWows() { + // CleanWindows(); + // var processes = Process.GetProcesses().OrderBy(p => p.Id).ToList(); + // foreach (var process in processes) { + // if (process.ProcessName == "UWow-64") { + // Console.WriteLine($"Found UWow-64 at pid {process.Id}"); + // if (ProcessTracked(process.Id)) + // continue; + // Track(process); + // } + // } + // } private static void Swap(int index) { index = (index - 1) % NumProc; @@ -190,6 +192,7 @@ internal static class Program { Console.WriteLine( $"Adding foreground window to tracked at index {i}..."); windows[i] = process; + break; } } } @@ -201,7 +204,7 @@ internal static class Program { windows[index] = window; Console.WriteLine($"Swapped window at index {i} to {index}"); // Toggle scroll lock off - keybd_event(0x91, 0, 0, 0); // KEYEVENTF_KEYDOWN + keybd_event(0x91, 0, 0, 0); // KEYEVENTF_KEYDOWN keybd_event(0x91, 0, 0x0002, 0); // KEYEVENTF_KEYUP return; } @@ -230,9 +233,7 @@ internal static class Program { } } - private static bool IsScrollLockOn() { - return (GetKeyState(0x91) & 1) == 1; - } + private static bool IsScrollLockOn() { return (GetKeyState(0x91) & 1) == 1; } [STAThread] private static void Main() { @@ -261,10 +262,10 @@ internal static class Program { HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed; void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) { - if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt) { - TrackWows(); - return; - } + // if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt) { + // TrackWows(); + // return; + // } int index; if (e.Key >= Keys.D0 && e.Key <= Keys.D9) {