Skip to content

sharadmittal/VirtualDesktopTrayNumber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VirtualDesktopTrayNumber (TrayNum)

A tiny Windows system-tray app that shows which virtual desktop you're on as a number in the notification area — and, unlike the alternatives, does not interfere with desktop switching.

TrayNum icon

Why this exists

Other tray indicators (e.g. dankrusi's Windows Virtual Desktop Helper) poll the undocumented virtual-desktop COM API on a tight loop — typically every 100 ms. That cross-process polling contends with explorer's switch animation, so holding Ctrl+Win+/ can glitch: the next desktop flashes, then snaps back; rapid switching lands on the wrong desktop. (See WindowsVirtualDesktopHelper issue #166.)

TrayNum never polls. It registers for desktop-change events and only redraws when the desktop actually changes, so it has nothing running during a switch to fight it. Switching stays smooth; idle CPU is ~0%.

How it works

  • UI: ~200 lines of C# / WinForms (NotifyIcon). The number is drawn as a vector glyph scaled to fill the tray tile.
  • Backend: Ciantic/VirtualDesktopAccessor (VirtualDesktopAccessor.dll, MIT). Its RegisterPostMessageHook posts a Windows message on every desktop change; TrayNum listens for it. All the fragile, per-Windows-build COM interop lives in that maintained DLL — TrayNum hardcodes no GUIDs.

Features

  • Desktop number in the tray, updated instantly on switch (1-based, matches Windows).
  • Right-click menu:
    • Box around number — draw a border around the digit (persisted).
    • Start with Windows — toggle launch at login (HKCU Run).
    • Exit.

Requirements

  • Windows 10 / 11 (built & tested on Windows 11 25H2, build 26200).
  • .NET Framework 4.x runtime (ships with Windows). No SDK needed to build — uses the in-box csc.exe.

Build

.\build.ps1

Produces TrayNum.exe next to VirtualDesktopAccessor.dll. Run it; the icon appears in the tray.

The x64 VirtualDesktopAccessor.dll must sit next to TrayNum.exe. It is bundled in this repo; updates are at the VirtualDesktopAccessor releases. If a future Windows build breaks desktop detection, drop in a newer DLL.

Updating for new Windows builds

You almost never need to touch this app. TrayNum.exe only calls stable exported function names, so it is unaffected by Windows updates. All the fragile, build-specific virtual-desktop COM interop lives in VirtualDesktopAccessor.dll.

  • Monthly cumulative updates (build revision bumps): no effect.
  • Annual feature updates (e.g. 24H2 → 25H2): usually no effect. Microsoft only occasionally reorders the internal virtual-desktop COM interface (24H2 was one such change).
  • If detection ever breaks — the tray number stops changing, or the app fails to launch — download the latest VirtualDesktopAccessor.dll from the Ciantic releases and drop it next to TrayNum.exe. No recompile needed.

Built and tested on Windows 11 25H2 (build 26200).

Credits

License

MIT.

About

Tiny Windows tray app showing the current virtual desktop number — event-driven, never polls, so it doesn't glitch Ctrl+Win+Arrow switching.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors