$ show kangyu-california/PersistentWindows
PersistentWindows is a Windows desktop utility that automatically captures and restores window positions and sizes when display configurations change (e.g., monitor connection/disconnection, resolution changes, docking/undocking, RDP sessions, or waking from sleep). It runs as a system tray application with no visible main window, using Win32 API hooks to monitor window events and LiteDB for persistent storage of window layouts. The core logic resides in a monolithic ~3000-line class (PersistentWindowProcessor) that handles event-driven capture, multi-pass restoration with timeout/retry, snapshot management, and virtual desktop awareness. The application also includes a 'webpage commander' overlay for keyboard-based browser tab navigation (Alt+W). While functionally robust and well-tested in the field (2000+ stars), the codebase exhibits significant technical debt: heavy use of deprecated patterns (Thread.Abort, magic numbers, hardcoded constants), no unit tests, and tight coupling of all logic into a single file. The Win32 API bridge and logging utilities are the most reusable components, though the overall architecture is monolithic and not designed for extension. GPLv3 licensed.
The LLM identified 4 files worth highlighting for reuse:
Comprehensive P/Invoke declarations for User32.dll, including window enumeration (EnumWindows, EnumChildWindows), window placement (SetWindowPos, GetWindowPlacement), monitor enumeration, DPI awareness, and hook registration (SetWinEventHook, SetWindowsHookEx). This file is self-contained and can be reused as a Win32 API wrapper in any .NET Windows application, with no internal dependencies on the rest of the repository.
Managed wrappers for MONITORINFO, MONITORINFOEX, and related structures used with EnumDisplayMonitors. Provides clear marshaling definitions and helper methods to extract monitor bounds, work area, and device name. Independently reusable in any .NET project that needs to query display configurations.
Static logging class that writes to the Windows Event Log (source 'PersistentWindows') and optionally the debug console. Provides Trace, Info, Error, and Event methods with conditional compilation for debug builds. Simple, self-contained, and easily adaptable to other .NET applications needing a thin logging abstraction with EventLog integration.
COM interop wrapper for the Windows 10 virtual desktop API (IVirtualDesktopManager). Exposes methods like IsWindowOnCurrentVirtualDesktop, MoveWindowToDesktop, and GetWindowDesktopId. Self-contained with only standard COM dependencies, reusable in any .NET project needing virtual desktop awareness. Demonstrates clean COM interface definitions and error handling.