; HotkeyManager.ahk — Enregistrement des raccourcis globaux et hotstrings (architecture §13). ; Aucun conflit silencieux : tout échec est consigné dans this.Conflicts et signalé (§13.3). class HotkeyManager { Registered := [] ; raccourcis effectivement enregistrés (pour désactivation propre) HotstringsOn := [] ; hotstrings effectivement activées Conflicts := [] ; [ "description — erreur" ] __New() { } Clear() { for hk in this.Registered { try Hotkey(hk, "Off") } for hs in this.HotstringsOn { try Hotstring(hs, "Off") } this.Registered := [] this.HotstringsOn := [] this.Conflicts := [] } ; callbacks : Map { picker, manager, newPrompt, replay, usePrompt (Func(id, ...)) } — usePrompt reçoit l'id en premier (Bind). RegisterAll(settings, prompts, callbacks) { this.Clear() this.TryHotkey(settings.PickerHotkey, callbacks["picker"], "Raccourci principal (Picker)") this.TryHotkey(settings.ManagerHotkey, callbacks["manager"], "Raccourci Gestionnaire") this.TryHotkey(settings.NewHotkey, callbacks["newPrompt"], "Raccourci Nouveau prompt") this.TryHotkey(settings.ReplayHotkey, callbacks["replay"], "Raccourci Rejouer le dernier") ; Épinglés : Ctrl+Alt+1..9 (§13.1). Bind fige l'id (les fermetures AHK capturent par référence). pinnedMap := Map() for p in prompts { if (p.Pinned >= 1 && p.Pinned <= 9) pinnedMap[p.Pinned] := p.Id } for n, id in pinnedMap { this.TryHotkey("^!" n, callbacks["usePrompt"].Bind(id), "Épinglé n° " n) } ; Raccourcis propres et hotstrings par prompt. for p in prompts { if (p.Hotkey != "") this.TryHotkey(p.Hotkey, callbacks["usePrompt"].Bind(p.Id), "Raccourci du prompt « " p.Title " »") if (p.Hotstring != "") { hs := "::" p.Hotstring try { Hotstring(hs, callbacks["usePrompt"].Bind(p.Id)) this.HotstringsOn.Push(hs) } catch as e { this.Conflicts.Push("Hotstring " hs " (« " p.Title " ») — " e.Message) } } } if (this.Conflicts.Length > 0) { Util.Log("Conflits de raccourcis : " this.Conflicts.Length) TrayTip(this.Conflicts.Length " raccourci(s) en conflit. Détail dans Paramètres.", "PromptKey — conflits de raccourcis") } } TryHotkey(hk, callback, label) { if (hk = "") return try { Hotkey(hk, callback) this.Registered.Push(hk) } catch as e { this.Conflicts.Push(label " (" hk ") — " e.Message) } } }