·10 min read
Desktop Grid: a click-through desktop overlay in Python and Qt
My Windows desktop is a pile of icons, and I wanted to draw labeled boxes on it: Work here, Games there. The icons are not mine to move, though. They belong to explorer.exe, and Windows rearranges them whenever the screen resolution or monitor count changes. So Desktop Grid does two jobs. It draws zones on top of the wallpaper, and it remembers where every icon should be.
The interesting part turned out to be the first one. An overlay that covers the whole desktop is easy. An overlay that covers the whole desktop and never steals a single click took me three commits in ten minutes to get right.
- Role
- Creator, built with Claude Code
- Period
- Jul 2026 to Aug 2026
- Status
- Released v1.1.0 (Aug 2, 2026)
- Stack
- Python, PySide6 (Qt), ctypes, Inno Setup
Download the exe from the latest release, draw a zone on your desktop, and see the click-through behaviour for yourself.
Get Desktop GridThe challenge
Three things fight each other here. The zones must be always visible, above the icons and below every application window. They must be editable in place, with labels to drag, a gear menu and edge grips. And everything else on that overlay must behave as if it were not there, so a double click on a shortcut still opens it.
The second problem is that I do not own the icons. The README describes the overlay as a click-through layer pinned just above the desktop, and the icons belong to Explorer. Any feature that keeps icons inside a zone has to ask another process to move them.
My responsibility
I wrote Desktop Grid alone, start to finish:
- The Qt overlay: painting, snapping, resize grips, hover labels, inline rename and the gear menu.
- The Win32 layer: input pass-through, z-order pinning and reading icons from Explorer.
- The icon memory: auto-keep zones, per-resolution layouts and the display-change watcher.
- Packaging: a tray app, an autostart toggle, an Inno Setup installer and the GitHub releases.
The project is about 1,557 lines of Python across four modules, main.py, overlay.py, desktop_icons.py and config.py.
A note on how it was built: many commits in this repository carry a Claude Code co-author trailer. I build with Claude Code as part of my normal workflow. I set the design, review every change and own the result.
How I approached it
Reading icons out of another process
The desktop icons are a SysListView32 control inside explorer.exe. You can send it messages, but anything with a pointer, such as an item's text, has to live in that process's memory. desktop_icons.py allocates buffers there, asks for the data, and copies it back:
remote_pt = self._alloc(ctypes.sizeof(POINT))
user32.SendMessageW(self.listview, LVM_GETITEMPOSITION, i, remote_pt)
kernel32.ReadProcessMemory(self.process, remote_pt, ctypes.byref(pt), ctypes.sizeof(POINT), None)Moving an icon is simpler, because LVM_SETITEMPOSITION packs x and y into one value. Two details are worth knowing. If the usual Progman window has no icon view, the code walks EnumWindows to find it under a WorkerW window, which is what wallpaper-engine style setups do. And "Auto arrange icons" must be off or Windows undoes every move, so the app turns it off and warns if it cannot.
Layouts that survive a monitor change
When you dock a laptop, Windows reshuffles the icons. Desktop Grid saves a full icon layout per display setup, using a key built from the virtual screen size and the monitor count:
def resolution_key():
vx, vy, vw, vh = virtual_screen()
monitors = ctypes.windll.user32.GetSystemMetrics(80) # SM_CMONITORS
return f"{vw}x{vh}@{monitors}"A timer polls that key every three seconds. When it changes, the overlay is rebuilt and, if auto-restore is on, the saved layout is applied after a 2.5 second delay, so Windows finishes its own shuffle first. Duplicate icon names are keyed as name (2), name (3) in encounter order, in both the save and the restore path, so the two always agree.
Zones that keep their icons
Auto-keep does the most work. A pinned zone remembers every icon inside it, and a loop every four seconds puts back any that escaped, adopts new ones dropped inside, and remembers ones you rearranged within the zone:
if zone_contains(zone, sx, sy):
if [sx, sy] != pos: # rearranged inside its zone -> remember
kept[key] = [sx, sy]
elif [sx, sy] != pos: # escaped the zone -> put it back
di.set_position_screen(idx, pos[0], pos[1])New zones are pinned by default (2135bb4, Jul 2026), so a freshly drawn zone starts keeping its icons right away.
The tkinter version lasted seven minutes
The first commit (4a63a82, Jul 2026, 04:20) was pure Python with ctypes and tkinter and already had snapping, a gear menu and per-resolution layouts, 1,422 lines in one go. Seven minutes later d88c7cf ported the whole UI to PySide6. The commit message says why: per-pixel alpha windows, antialiased shapes, and a Qt colour dialog with a built-in screen eyedropper and hex field. The overlay design did not change, only the toolkit under it.
The overlay that blocked the whole desktop
The port came with a plan for pass-through: answer WM_NCHITTEST per point, return HTCLIENT over a label, gear or border, and HTTRANSPARENT everywhere else. It did not work, and I found out within three minutes. 577149b (Jul 2026, 04:30) says what happened, in my own commit message: Qt6 translucent top-level windows swallow input even on fully transparent pixels, and HTTRANSPARENT does not forward clicks to other processes, so the overlay blocked the whole desktop.
The fix is blunt and works. A timer polls the cursor every 60 ms, asks which interactive element is under it, and flips one extended window style:
def _set_click_through(self, enabled):
ex = _get_long(hwnd, GWL_EXSTYLE)
ex = (ex | WS_EX_TRANSPARENT) if enabled else (ex & ~WS_EX_TRANSPARENT)
_set_long(hwnd, GWL_EXSTYLE, ex)
def _hover_poll(self):
...
zone, _kind, _ = self._element_at(x, y)
self._set_click_through(zone is None)With WS_EX_TRANSPARENT on, every click goes straight to the icons underneath. Over a label, gear or border it is switched off and the overlay takes input. There is one trap that the diff shows: setWindowFlag() recreates the native window and wipes the extended styles, so _apply_base_styles re-applies WS_EX_TOOLWINDOW, WS_EX_NOACTIVATE and the transparent bit after every flag change.
I left one wart in the file. The docstring at the top of overlay.py still says WM_NCHITTEST is answered per point, which describes the approach I replaced.
Ten commits for a feature I took back
On Jul 31, between 04:59 and 05:25, I built a "dragging mode", where moving a zone carries its icons along. It started simple (1d981dd) and then grew, with every commit fixing a side effect of the one before:
a00c845: icons drifted during a drag, so I captured base positions once and wrotebase + total deltaon every update, throttled to about 22 updates a second.cb08298anda05302c: zones could collide, so a one-icon-cell gap was enforced, and the icons only settled on spots with no foreign icons in them.5b9033d: deleted icons stayed in a zone's kept list forever, and their old coordinates kept stretching the border. Missing icons are now forgotten after about ten seconds.c9d7dc0,b21aedaand203168d: fit-to-icons, then auto-fit, then a change so that auto-fit zones follow their icons instead of snapping them back.
At 05:29 the next commit was cfb8b58, "Revert to pre-dragging-mode state (32cb8aa)". It is also the commit that v1.0.0 points to, published two minutes later. It removed 270 lines and added 27, and a diff between 32cb8aa and cfb8b58 shows only the logo image differing. The message does not say why, and I will not invent a reason. What the log shows is a feature whose rules multiplied with every commit, while the original behaviour, pinned zones carrying their kept icons when moved, was already in the shipped README. I kept the simple version.
lines of Python in four modules
cursor poll that toggles click-through
commits of dragging mode before the revert
lines removed by that one revert
Project journey
Nearly all of the app was written on Jul 31, and v1.0.0 was published the same morning.
Jul 2026
First commit
4a63a82: zones, snapping, auto-keep and layouts in tkinter
Jul 2026
Qt port
d88c7cf and 577149b: PySide6 and the click-through fix
Jul 2026
Zone styling
891d0bd and 0583f50: border radius and per-zone opacity
Jul 2026
Autostart and logo
909d3b7: Startup shortcut and exe build support
Jul 2026
Dragging mode, revert and v1.0.0
1d981dd to cfb8b58, 04:59 to 05:29, v1.0.0 on the revert
Jul 2026
Inline rename
f2c0086: rename in the title pill, zones created instantly, v1.0.1
Aug 2026
Tray start
8f3260b: autostart opens straight to the tray, v1.0.2
Aug 2026
Installer
63e248b: Inno Setup, exe metadata, v1.1.0
Beyond the launch
Two small releases show what real use asked for. f2c0086 (v1.0.1) removed the naming prompt: drawing a zone now creates it as Zone with auto-keep on, and you rename it in place by double clicking the title. 8f3260b (v1.0.2) stopped the control panel opening at every Windows start, since autostart now passes --tray. The release notes admit the catch: an older autostart shortcut has to be toggled off and on to pick up the change.
63e248b (Aug 2026) added an Inno Setup script: per-user install without admin, a Start Menu shortcut, an optional tray autostart, and a step that kills the running instance before installing or uninstalling. Limits I can see in the repo: Auto arrange must stay off, per the README, and install_startup.bat hardcodes a Python 3.12 path for the startup shortcut.
The outcome
Desktop Grid is released and public. The verifiable facts:
- Four releases,
v1.0.0on Jul 31, 2026 tov1.1.0on Aug 2, 2026, with a ready exe and an installer (DesktopGrid-Setup-1.1.0.exe). - The v1.1.0 exe is 49,022,656 bytes and the installer 50,863,705 bytes, because each carries Python and Qt. TaskPad, my C# tool, is about 1 MB. That is the cost of the stack I chose here.
- Zones with labels, colours, shapes, snapping, lock, auto-keep, per-resolution icon layouts, a tray icon and inline rename.
The lesson I keep from this project is about a stack's edges. Qt gave me good rendering and an overlay that blocked the whole desktop, and the answer was a single Win32 style bit, not a cleverer Qt trick.
The click-through logic is in `overlay.py` and the Explorer icon access is in `desktop_icons.py`, both short enough to read in one sitting.
Read the code on GitHubEvidence
- Repository: ddatunashvili/desktop_organizer
- Latest release: Desktop Grid v1.1.0
- Commits relied on:
4a63a82,d88c7cf,577149b,2135bb4,1d981dd,a00c845,a05302c,5b9033d,cfb8b58,f2c0086,8f3260b,63e248b - Files:
README.md,main.py,overlay.py,desktop_icons.py,config.py,installer.iss
Not verified: I did not run Desktop Grid for this write-up. The behaviour comes from the code, commit messages and release notes, and the reason for the revert is not recorded in the history. File sizes are the release asset sizes reported by GitHub.
#python#pyside6#windows#ctypes
Keep reading
Have a project in mind?