Implement sequence mode

This commit is contained in:
2025-08-31 20:48:07 +02:00
parent 0e3f2005d1
commit 1cdfba0b14
2 changed files with 142 additions and 4 deletions

View File

@@ -35,9 +35,52 @@ namespace DD2Switcher {
}
}
public static void StartSequenceMode() {
if (FirstIndex >= 0 && LastIndex >= 0 && FirstIndex <= LastIndex) {
SequenceMode = true;
CurrentSequenceIndex = FirstIndex;
TabTo(CurrentSequenceIndex + 1); // Tab to first window
}
}
public static void NextSequenceStep() {
if (!SequenceMode)
return;
CurrentSequenceIndex++;
if (CurrentSequenceIndex > LastIndex) {
// End of sequence
ExitSequenceMode();
} else {
TabTo(CurrentSequenceIndex + 1);
}
}
public static void ExitSequenceMode() {
SequenceMode = false;
CurrentSequenceIndex = -1;
}
public static void UpdateSequenceHotkey(Keys newKey) {
// Unregister old hotkey
if (sequenceHotkeyId != -1) {
HotKeyManager.UnregisterHotKey(sequenceHotkeyId);
}
// Register new hotkey
sequenceHotkeyId = HotKeyManager.RegisterHotKey(newKey, KeyModifiers.NoRepeat);
SequenceKeybind = newKey;
}
// Static properties for first/last selection persistence
public static int FirstIndex { get; set; } = -1;
public static int LastIndex { get; set; } = -1;
// Sequence mode state
public static bool SequenceMode { get; set; } = false;
public static int CurrentSequenceIndex { get; set; } = -1;
public static Keys SequenceKeybind { get; set; } = Keys.F1;
private static int sequenceHotkeyId = -1;
private static int ActiveIndex = -1;
private static bool AltPressed = false;
@@ -358,9 +401,25 @@ namespace DD2Switcher {
for (int i = 0; i < 9; i++) HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt);
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
sequenceHotkeyId = HotKeyManager.RegisterHotKey(SequenceKeybind, KeyModifiers.NoRepeat);
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
// Check for sequence mode keybind
if (e.Key == SequenceKeybind && e.Modifiers == KeyModifiers.NoRepeat) {
if (SequenceMode) {
NextSequenceStep();
} else {
StartSequenceMode();
}
return;
}
// Cancel sequence mode on any manual window switching
if (SequenceMode && e.Modifiers == KeyModifiers.Alt) {
ExitSequenceMode();
}
if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt && IsCapsLockOn()) {
TrackProcess();
ToggleCapsLock();