Update 1: Revised macro posted in the original posting above.
- Why the update: two switches, one flash.
Windows keeps two separate dark/light settings: AppsUseLightTheme (apps) and SystemUsesLightTheme (Windows itself, such as the taskbar and Start menu). Both must be flipped for a complete mode change. Even then, windows that are already open, such as File Explorer, only partly repaint until Windows is told the theme has changed, so the macro now also sends the WM_SETTINGCHANGE "ImmersiveColorSet" broadcast.
All three steps now run in a single PowerShell call inside the VM, instead of separate commands that each flashed a console window. The result is one brief PowerShell flash per run. As far as I can find, that is the minimum when running as the logged-in Windows user: -WindowStyle Hidden still flashes, and conhost --headless hid the window but made no change while still reporting success.
Other changes: the macro checks that the VM is running, retries while Windows is still booting, and uses a Semaphore Lock because the "Windows launches" trigger fires twice (VM.app starts two helper processes).
- Dictation (F5) can trigger a false run (a macOS bug).
On macOS 27, pressing F5 to start Dictation sometimes makes macOS send every running app a "System appearance change" about half a second later, even though the appearance has not changed. The system log shows loginwindow, SystemUIServer, Control Center, Safari and Keyboard Maestro Engine all logging it at the same moment, with identical appearance values before and after. Keyboard Maestro is just reacting to it, so the Appearance Changed trigger fires.
In this macro the effect is harmless: it rewrites the mode Windows already has, with its usual single PowerShell flash. I tried filtering it out, but both options were worse (a USB Device Key trigger on F5 stopped Dictation from starting, and a global variable would add state for a cosmetic issue), so I have left it and documented it in the macro's comments.
Resuming a suspended VM is still not handled, as before; happy to add it if anyone needs it.
Keyboard Maestro 11.1.1 / macOS 27.0.1