Compare commits
2 Commits
4aaedac17c
...
be2c6f7829
Author | SHA1 | Date | |
---|---|---|---|
be2c6f7829 | |||
7beb55e3ce |
@@ -7,7 +7,7 @@ using System.Windows.Forms;
|
|||||||
namespace DD2Switcher;
|
namespace DD2Switcher;
|
||||||
|
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
private static int NumProc = 10;
|
private static int NumProc = 19;
|
||||||
private static Process[] windows = new Process[NumProc];
|
private static Process[] windows = new Process[NumProc];
|
||||||
private static int ActiveIndex = -1;
|
private static int ActiveIndex = -1;
|
||||||
|
|
||||||
@@ -139,6 +139,7 @@ internal static class Program {
|
|||||||
index = (index - 1) % NumProc;
|
index = (index - 1) % NumProc;
|
||||||
if (index < 0) index = NumProc - 1;
|
if (index < 0) index = NumProc - 1;
|
||||||
if (index >= NumProc) return;
|
if (index >= NumProc) return;
|
||||||
|
CleanWindows();
|
||||||
Console.WriteLine($"Swapping window at index {index}");
|
Console.WriteLine($"Swapping window at index {index}");
|
||||||
var process = GetForegroundProcess();
|
var process = GetForegroundProcess();
|
||||||
if (process == null) return;
|
if (process == null) return;
|
||||||
@@ -178,6 +179,7 @@ internal static class Program {
|
|||||||
index = (index - 1) % NumProc;
|
index = (index - 1) % NumProc;
|
||||||
if (index < 0) index = NumProc - 1;
|
if (index < 0) index = NumProc - 1;
|
||||||
if (index >= NumProc) return;
|
if (index >= NumProc) return;
|
||||||
|
CleanWindows();
|
||||||
Console.WriteLine($"Tab to window at index {index}");
|
Console.WriteLine($"Tab to window at index {index}");
|
||||||
|
|
||||||
var window = windows[index];
|
var window = windows[index];
|
||||||
@@ -206,12 +208,18 @@ internal static class Program {
|
|||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < NumProc; i++) {
|
// Register main number keys (0-9)
|
||||||
windows[i] = null;
|
for (int i = 0; i < 10; i++) {
|
||||||
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt);
|
||||||
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt | KeyModifiers.Shift);
|
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt | KeyModifiers.Shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register numpad keys (1-9)
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt);
|
||||||
|
HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt | KeyModifiers.Shift);
|
||||||
|
}
|
||||||
|
|
||||||
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
|
||||||
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
||||||
|
|
||||||
@@ -221,15 +229,25 @@ internal static class Program {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index;
|
||||||
|
if (e.Key >= Keys.D0 && e.Key <= Keys.D9) {
|
||||||
|
index = e.Key - Keys.D0;
|
||||||
|
}
|
||||||
|
else if (e.Key >= Keys.NumPad1 && e.Key <= Keys.NumPad9) {
|
||||||
|
index = 10 + (e.Key - Keys.NumPad1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Modifiers == KeyModifiers.Alt) {
|
if (e.Modifiers == KeyModifiers.Alt) {
|
||||||
TabTo(e.Key - Keys.D0);
|
TabTo(index);
|
||||||
}
|
}
|
||||||
else if (e.Modifiers == (KeyModifiers.Alt | KeyModifiers.Shift)) {
|
else if (e.Modifiers == (KeyModifiers.Alt | KeyModifiers.Shift)) {
|
||||||
Swap(e.Key - Keys.D0);
|
Swap(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.CancelKeyPress += (sender, e) => { Process.GetCurrentProcess().Kill(); };
|
Console.CancelKeyPress += (sender, e) => { Process.GetCurrentProcess().Kill(); };
|
||||||
while (true)
|
while (true)
|
||||||
System.Threading.Thread.Sleep(100000);
|
System.Threading.Thread.Sleep(100000);
|
||||||
|
Reference in New Issue
Block a user