Implement "find all wows" button
This commit is contained in:
@@ -24,16 +24,22 @@ internal static class Program {
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool AllocConsole();
|
||||
|
||||
private static void AdjustAffinities() {
|
||||
private static void CleanWindows() {
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
var window = windows[i];
|
||||
if (window == null) continue;
|
||||
if (window.MainWindowHandle == IntPtr.Zero) {
|
||||
Console.WriteLine($"Window at index {i} has no main window, removing from tracked windows");
|
||||
windows[i] = null;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AdjustAffinities() {
|
||||
CleanWindows();
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
var window = windows[i];
|
||||
if (window == null) continue;
|
||||
if (i != ActiveIndex) {
|
||||
try {
|
||||
window.ProcessorAffinity = defaultAffinity;
|
||||
@@ -56,14 +62,10 @@ internal static class Program {
|
||||
}
|
||||
|
||||
private static void AdjustPriorities() {
|
||||
CleanWindows();
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
var window = windows[i];
|
||||
if (window == null) continue;
|
||||
if (window.MainWindowHandle == IntPtr.Zero) {
|
||||
Console.WriteLine($"Window at index {i} has no main window, removing from tracked windows");
|
||||
windows[i] = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i != ActiveIndex) {
|
||||
try {
|
||||
@@ -100,27 +102,25 @@ internal static class Program {
|
||||
return foregroundProcess;
|
||||
}
|
||||
|
||||
private static void TrackWindow() {
|
||||
Console.WriteLine("Toggling foreground window as tracked...");
|
||||
var foregroundProcess = GetForegroundProcess();
|
||||
if (foregroundProcess == null) return;
|
||||
Console.WriteLine($"Foreground process: {foregroundProcess}");
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
var window = windows[i];
|
||||
if (window != null && window.Id == foregroundProcess.Id) {
|
||||
Console.WriteLine($"Removing foreground window from tracked at index {i}...");
|
||||
windows[i] = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
var window = windows[i];
|
||||
if (window == null) {
|
||||
Console.WriteLine($"Adding foreground window to tracked at index {i}...");
|
||||
windows[i] = foregroundProcess;
|
||||
return;
|
||||
private static void TrackWows() {
|
||||
CleanWindows();
|
||||
var processes = Process.GetProcesses();
|
||||
foreach (var process in processes) {
|
||||
if (process.ProcessName == "UWow-64") {
|
||||
Console.WriteLine($"Found UWow-64 at pid {process.Id}");
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
if (windows[i] != null && windows[i].Id == process.Id) {
|
||||
Console.WriteLine($"UWow-64 is already tracked at index {i}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
if (windows[i] == null) {
|
||||
windows[i] = process;
|
||||
Console.WriteLine($"Added UWow-64 to tracked windows at index {i}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ internal static class Program {
|
||||
|
||||
static void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
|
||||
if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt) {
|
||||
TrackWindow();
|
||||
TrackWows();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user