Clean up code a little
This commit is contained in:
@@ -102,25 +102,35 @@ internal static class Program {
|
||||
return foregroundProcess;
|
||||
}
|
||||
|
||||
private static Boolean ProcessTracked(int id) {
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
if (windows[i] != null && windows[i].Id == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void Track(Process process) {
|
||||
for (int i = 0; i < NumProc; i++) {
|
||||
if (windows[i] == null) {
|
||||
windows[i] = process;
|
||||
Console.WriteLine($"Added {process.ProcessName} to tracked windows at index {i}");
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (ProcessTracked(process.Id))
|
||||
continue;
|
||||
Track(process);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user