From b5446516e4c446cfde2b34d7036d29b6ceec6212 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 24 May 2025 23:56:23 +0200 Subject: [PATCH] Add sorting for process list and implement scroll lock toggle --- DD2Switcher/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DD2Switcher/Program.cs b/DD2Switcher/Program.cs index ab8de75..23a87b3 100644 --- a/DD2Switcher/Program.cs +++ b/DD2Switcher/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -26,6 +27,9 @@ internal static class Program { [return:MarshalAs(UnmanagedType.Bool)] static extern bool AllocConsole(); + [DllImport("user32.dll")] + 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++) { var window = windows[i]; @@ -128,7 +132,7 @@ internal static class Program { private static void TrackWows() { CleanWindows(); - var processes = Process.GetProcesses(); + 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}"); @@ -178,6 +182,9 @@ internal static class Program { windows[i] = windows[index]; 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, 0x0002, 0); // KEYEVENTF_KEYUP return; } }