Add sorting for process list and implement scroll lock toggle

This commit is contained in:
2025-05-24 23:56:23 +02:00
parent c28bc4ac69
commit b5446516e4

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
@@ -26,6 +27,9 @@ internal static class Program {
[return:MarshalAs(UnmanagedType.Bool)] [return:MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole(); 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() { private static void CleanWindows() {
for (int i = 0; i < NumProc; i++) { for (int i = 0; i < NumProc; i++) {
var window = windows[i]; var window = windows[i];
@@ -128,7 +132,7 @@ internal static class Program {
private static void TrackWows() { private static void TrackWows() {
CleanWindows(); CleanWindows();
var processes = Process.GetProcesses(); var processes = Process.GetProcesses().OrderBy(p => p.Id).ToList();
foreach (var process in processes) { foreach (var process in processes) {
if (process.ProcessName == "UWow-64") { if (process.ProcessName == "UWow-64") {
Console.WriteLine($"Found UWow-64 at pid {process.Id}"); Console.WriteLine($"Found UWow-64 at pid {process.Id}");
@@ -178,6 +182,9 @@ internal static class Program {
windows[i] = windows[index]; windows[i] = windows[index];
windows[index] = window; windows[index] = window;
Console.WriteLine($"Swapped window at index {i} to {index}"); 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; return;
} }
} }