Skip to content
Raisul Sohan

Windows Desktop Utility & System Tool

LazyPin

Seamless Native Title-Bar Always-On-Top Pin Utility for Windows

Solo Software Architect & Systems Developer Windows 10 & 11 Desktop Utility • C# / Win32 API • v1.0.3

  • GitHub stars: 1
  • Downloads: 7
  • v1.1.0 · 1 month ago
LazyPin

A lightweight, zero-latency Windows 10 & 11 desktop utility that docks a native-looking Always-On-Top pin button directly beside window caption controls (minimize/maximize/close) on any active window. Engineered with Win32 C# interop, process-scoped WinEvent hooks for zero-jitter 60 FPS tracking, dynamic DWM & WM_NCHITTEST caption hit-testing, and automatic full-screen detection.

The challenge

Multitasking developers, video editors, designers, and students routinely need secondary reference windows—such as video tutorials, calculators, sticky notes, terminal logs, or API documentation—to remain anchored on top of primary workspace applications. Conventional solutions like Microsoft PowerToys rely on arbitrary keyboard shortcuts (Win+Ctrl+T) that disrupt creative flow and provide zero visual feedback on the window frame. Other third-party utilities suffer from heavy background overhead, require elevated administrative rights, or produce noticeable latency and visual jitter where the pin button lags behind the window during dragging.

Core Technical Challenges:
1. Zero-Jitter Real-Time Window Tracking: Maintaining an overlay button anchored beside the minimize button at 60+ FPS without visual drift or separation during aggressive window dragging or Aero Snap resizing. System-wide WinEvent hooks flood the message pump; the tracking hook had to be strictly scoped to the active window's thread process ID.
2. Dynamic Custom Caption Bar Hit-Testing: Modern web browsers (Chrome, Edge, Brave) and Electron applications (Claude Desktop, VS Code, Spotify) draw custom interactive tabs across the title bar rather than standard Win32 non-client areas. Static pixel coordinates collide with tabs. The utility required a non-blocking hit-testing heuristic using DWM APIs and WM_NCHITTEST with strict timeout fallbacks to prevent freezing on hung processes.
3. Non-Intrusive Z-Order & Fullscreen Intelligence: Accurately toggling HWND_TOPMOST without stealing keyboard focus, keeping the pin button overlay promoted only when needed, auto-hiding during borderless full-screen games and media playback, and operating quietly from the System Tray with zero administrative privileges required.

The solution

1. Process-Scoped WinEvent Hook Architecture: Scopes SetWinEventHook(EVENT_OBJECT_LOCATIONCHANGE) exclusively to the thread process ID of the active target window. By eliminating global system-wide message flooding, the overlay moves in lockstep with window dragging at 60+ FPS with zero button jitter and 0% idle CPU overhead.

2. Dynamic DWM & WM_NCHITTEST Caption Hit-Testing: Combines DwmGetWindowAttribute with non-blocking SendMessageTimeout hit-testing across title-bar coordinates. Detects custom caption controls and tab strips across Chrome, Edge, Brave, and Electron apps, with IsHungAppWindow protection preventing locks on unresponsive processes.

3. Single-Click Always-On-Top Toggle & Z-Order Management: Uses native Win32 SetWindowPos with HWND_TOPMOST and HWND_NOTOPMOST flags to pin and unpin target windows instantly. Visual state transitions immediately to a vibrant cyan accent (#60CDFF) upon pinning.

4. Fullscreen Intelligence & Auto-Hide: Implements CoversMonitor to evaluate whether active windows occupy full monitor bounds (such as borderless games, media players, or F11 browser views), automatically hiding the overlay to preserve immersive experiences.

5. Per-Monitor DPI-Aware Scaling & Windows Theme Adaptation: Dynamically queries GetDpiForWindow to scale button dimensions, padding, and icons precisely across mixed-DPI multi-monitor setups (100%–250%), harmonizing with Windows 10 & 11 dark and light title bars.

6. Silent System Tray Operation & Zero-UAC Installation: Runs unobtrusively in the Windows notification area with startup toggle controls, consuming ~15 MB RAM. Ships with an Inno Setup installer that targets per-user AppData directories, requiring zero administrator elevation.

Highlights

  • Single-click Always-On-Top toggle docked directly beside window minimize buttons
  • Seamless native design harmonizing with Windows 10 & 11 caption geometry and themes
  • Zero-jitter, frame-perfect window tracking via process-scoped WinEvent location hooks
  • Intelligent DWM & WM_NCHITTEST heuristics supporting Chrome, Edge, and custom client tabs
  • Fullscreen intelligence automatically hiding overlays during games and media playback
  • Low-overhead System Tray integration consuming ~15 MB RAM with 0% idle CPU usage
  • Zero administrator privileges (UAC) required; 100% free and open-source (MIT)

Built with

  • Windows 10/11
  • C#
  • Win32 API
  • Desktop Utility
  • PowerShell
  • Always on Top
  • Open Source