A lightweight always-on-top Windows overlay that displays the real-time state of Caps Lock, Num Lock, and Scroll Lock using a minimal, draggable UI built with PyQt6.
- 🔒 Displays Caps Lock, Num Lock, and Scroll Lock states in real time
- 🪟 Frameless, transparent, always-on-top floating overlay
- 🖱️ Drag & drop positioning
- 📐 Optional axis-constrained movement while dragging (Shift key)
- 📌 Position locking / unlocking (middle mouse click)
- 👻 Automatic auto-hide when locked and inactive
- 💾 Persistent configuration stored as JSON
- 📐 Relative screen positioning (resolution-independent)
- 🖥️ Automatically adapts to screen resolution changes
- 🎨 Automatic Windows light / dark theme detection
- 🎯 Windows accent color integration
- ⚡ Very low CPU usage (timer-based polling)
The application:
- Reads the state of keyboard lock keys using the Win32 API (
GetKeyState) - Draws circular indicators using
QPainter - Polls system state using lightweight timers:
- Keyboard lock state: 150 ms
- Windows theme & accent color: 5 seconds
- Z-order enforcement (always on top): 50 ms
- Automatically shows the overlay when a lock state changes
- Hides the overlay after a configurable timeout when position locking is enabled
- Stores its relative screen position so it adapts to resolution changes
- Windows 11
- Python 3.10+ (recommended)
- Python packages:
PyQt6
This application has only been tested on Windows 11.
It has not been tested on other Windows versions, nor on non-Windows operating systems.
While it may work on Windows 10, compatibility is not guaranteed.
Install dependencies:
pip install PyQt6python state_lock_overlay.pyOn first launch, the overlay will appear near the bottom-right of the primary screen.
| Action | Mouse Button / Key |
|---|---|
| Move overlay | Left click + drag |
| Lock / unlock movement | Middle click |
| Save configuration & exit | Right click |
| Axis-constrained move | Hold Shift while dragging |
The application stores its persistent state in:
~/Documents/.state_lock_settings.json
{
"rel_x": 0.759,
"rel_y": 0.962,
"locked": false,
"hide_timer_in_ms": 3000
}-
rel_x,rel_y
Relative screen position (0.0 – 1.0), resolution-independent -
locked
Prevents accidental movement and enables auto-hide behavior -
hide_timer_in_ms
Time (in milliseconds) after which the overlay automatically hides when locked and no state changes occur
The overlay automatically adapts to Windows system settings:
- Detects light / dark mode
- Reads and applies the system accent color
- Adjusts inactive indicator contrast accordingly
This is handled via the Windows Registry:
HKCU\Software\Microsoft\Windows\DWMHKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
The project includes a ready-to-use build system based on PyInstaller, with size optimizations and UPX compression.
build.bat– Automated build scriptStateLockOverlay.spec– Custom PyInstaller specificationupx.exe– Executable compression (optional but recommended)
- Windows 11
- Python 3.10+
PyInstaller(installed automatically by the script)upx.exeavailable inPATHor project directory
build.batThe script will:
- Verify Python installation
- Install PyInstaller if missing
- Clean previous
build/anddist/folders - Build the executable using
StateLockOverlay.spec - Produce the final binary
dist/StateLockOverlay.exe
The executable is built with:
- ❌ No console window (
console=False) - 🧹 Excluded unused PyQt6 modules
- 📦 UPX compression enabled
- ⚡ Optimized startup and reduced size
To have State Lock Overlay start automatically when Windows boots, you can place the executable in the user startup folder.
- Press Win + R
- Type:
shell:startup
- Press Enter
- Copy
StateLockOverlay.exe(or a shortcut to it) into the folder that opens
On the next Windows startup, the overlay will launch automatically.
💡 Tip
Using a shortcut instead of the executable allows you to easily replace the binary or change its location without modifying the startup folder again.
The codebase is intentionally structured to allow future extensions such as:
- 🖥️ Proper multi-monitor support
- 🐧 Linux support (requires replacing Win32 API usage and add fallbacks)
- ⚙️ System tray integration for options
This project is provided as-is for personal or educational use.
You are free to modify, extend, and redistribute it.



