The Phantom Observer
Allow a cabal of watching spirits to react simultaneously when a mortal shifts window focus or triggers an arcane event.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Ethereal Surveillance
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class WindowSubject {
__New() {
this.observers := []
this.current_window := ""
}
Attach(observer) {
this.observers.Push(observer)
}
Notify() {
for index, obs in this.observers {
obs.Update(this.current_window)
}
}
Poll() {
active := WinGetTitle("A")
if (active != this.current_window) {
this.current_window := active
this.Notify()
}
}
}
class PoltergeistWatcher {
__New(name) {
this.name := name
}
Update(new_window) {
ToolTip(this.name . " saw mortal switch to: " . new_window)
Sleep(500)
ToolTip()
}
}
subject := WindowSubject()
subject.Attach(PoltergeistWatcher("Ghost Alpha"))
; In a real script, run this in a SetTimer
subject.Poll()
Runic Tags:
#autohotkey
#observer
#automation
#poltergeist