Compare commits
2 Commits
b5446516e4
...
9de3ae43d5
Author | SHA1 | Date | |
---|---|---|---|
9de3ae43d5 | |||
886258e4c3 |
@@ -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++) {
|
||||
@@ -120,29 +121,48 @@ internal static class Program {
|
||||
}
|
||||
|
||||
private static void Track(Process process) {
|
||||
// First find the first null slot
|
||||
int firstNullIndex = -1;
|
||||
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;
|
||||
}
|
||||
firstNullIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (firstNullIndex == -1) {
|
||||
Console.WriteLine("No slots available for tracking");
|
||||
return;
|
||||
}
|
||||
|
||||
// Compact the array by shifting non-null elements to the left
|
||||
for (int i = firstNullIndex + 1; i < NumProc; i++) {
|
||||
if (windows[i] != null) {
|
||||
windows[firstNullIndex] = windows[i];
|
||||
windows[i] = null;
|
||||
firstNullIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the new process at the first null slot
|
||||
windows[firstNullIndex] = process;
|
||||
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 Swap(int index) {
|
||||
index = (index - 1) % NumProc;
|
||||
if (index < 0)
|
||||
@@ -172,6 +192,7 @@ internal static class Program {
|
||||
Console.WriteLine(
|
||||
$"Adding foreground window to tracked at index {i}...");
|
||||
windows[i] = process;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,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() {
|
||||
@@ -243,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) {
|
||||
|
Reference in New Issue
Block a user