Overview
The PowerToys Runner is the main executable (PowerToys.exe) that serves as the host process for all PowerToys modules. It manages module lifecycle, hotkey registration, the system tray icon, and communication with the Settings UI.
Core Responsibilities
Initialization Sequence
The Runner follows a specific initialization order to ensure all components are ready before modules are enabled.1. Process Initialization
src/runner/main.cpp:181
2. Tray Icon Startup
doc/devdocs/core/runner.md:37-65
3. Module Loading
src/runner/powertoy_module.cpp:13-24
4. Settings Application
doc/devdocs/core/runner.md:130-138
5. Keyboard Hook Registration
doc/devdocs/core/runner.md:120-128
System Tray Icon
The system tray icon is the primary UI element of the Runner, providing quick access to settings and module controls.Implementation
doc/devdocs/core/runner.md:49-56, src/runner/tray_icon.cpp
Window Procedure
doc/devdocs/core/runner.md:57-61
Tray Icon Actions
Left Click - Quick Access Flyout:doc/devdocs/core/runner.md:66-68, doc/devdocs/core/runner.md:103-112
Double Click - Dashboard:
doc/devdocs/core/runner.md:71-74
Right Click - Context Menu:
The context menu is defined in resource files:
doc/devdocs/core/runner.md:114-119
Module Management
Module Discovery
The Runner scans for module DLLs in themodules/ directory:
WinUI3Apps/ folder to avoid DLL conflicts.
Reference: doc/devdocs/core/runner.md:17-19
Module Lifecycle
src/runner/powertoy_module.h, src/runner/powertoy_module.cpp
Centralized Keyboard Hook
The Runner uses a low-level keyboard hook to intercept hotkey presses for all modules. This centralized approach prevents performance issues from multiple hooks.Implementation
-
Early Exit on PowerToys-Generated Input
- Uses
dwExtraInfoflag to ignore synthetic keystrokes - Prevents infinite loops and unnecessary processing
- Uses
-
No Key Press Detection
- Returns immediately if no keys are actually pressed
- Avoids processing modifier-only events
-
Metadata Caching
- Caches hotkey information to avoid repeated lookups
- Uses efficient data structures for fast matching
doc/devdocs/core/runner.md:120-128
Hotkey Registration
Modules report their hotkeys to the Runner, which registers them with the centralized keyboard hook.Hotkey Collection
src/modules/interface/powertoy_module_interface.h:111-124
Hotkey Conflict Detection
The Settings UI checks for hotkey conflicts across modules:- Each module implements
get_hotkeys()orGetHotkeyEx() - Settings UI collects all hotkeys via Runner IPC
- Conflicts are displayed in the Settings UI with warnings
- User can resolve conflicts by changing hotkeys
doc/devdocs/core/settings/settings-implementation.md:74-108
IPC with Settings UI
The Runner communicates with the Settings UI process via Windows Named Pipes using a bidirectional JSON protocol.Pipe Initialization
doc/devdocs/core/runner.md:76-91, src/runner/settings_window.cpp
Message Types
Runner → Settings UI:doc/devdocs/core/settings/runner-ipc.md:16-20
Message Processing
doc/devdocs/core/runner.md:157, src/runner/tray_icon.cpp:157
Update Management
The Runner handles automatic update checking and installation.Update Checking
doc/devdocs/core/runner.md:196
Update Installation
When the user approves an update from the Settings UI:- Download installer to temp directory
- Verify digital signature
- Close all PowerToys processes
- Launch installer with elevation
- Exit Runner (installer will restart after completion)
src/runner/UpdateUtils.cpp
Key Source Files
| File | Purpose | Reference |
|---|---|---|
main.cpp | Entry point, initialization, message loop | src/runner/main.cpp:150 |
powertoy_module.h/cpp | Module loading and management | src/runner/powertoy_module.cpp:153 |
tray_icon.cpp | System tray icon and menu | src/runner/tray_icon.cpp:156 |
settings_window.cpp | Settings UI communication | src/runner/settings_window.cpp:160 |
general_settings.cpp | General settings loading/saving | src/runner/general_settings.cpp:163 |
centralized_kb_hook.cpp | Keyboard hook implementation | src/runner/centralized_kb_hook.cpp:184 |
centralized_hotkeys.cpp | Hotkey registration logic | src/runner/centralized_hotkeys.cpp:181 |
UpdateUtils.cpp | Update checking and installation | src/runner/UpdateUtils.cpp:196 |
trace.cpp | Telemetry implementation | src/runner/trace.cpp:172 |
Next Steps
Module Interface
Learn how to implement a PowerToys module
Settings System
Understand the settings architecture and IPC
Architecture Overview
High-level system architecture
Common Libraries
Shared utilities and helper functions