0

I've been using the particularly handy EnumWindows() to collect the handles of currently open windows. Unfortunately, this function only picks up handles from the current desktop - if I open a new virtual desktop and open windows there, only the currently shown desktop's windows will be enumerated.

The Windows virtual desktop API docs seem pretty thin on the ground - does anyone know of a solution that would let me pick up window handles from all open windows across all virtual desktops?

user3896248
  • 347
  • 1
  • 5
  • 16
  • 1
    Create a process on that virtual desktop and enumerate windows there – David Heffernan Sep 20 '19 at 09:53
  • Not sure this works - EnumWindows literally gets handles from whatever desktop is currently visible, no matter what process it's running from – user3896248 Sep 20 '19 at 10:03
  • That doesn't sound right. Each process has an affinity with a desktop and when you do things like `EnumWindows`, `FindWindow` etc., that operates in the desktop to which the process is associated. – David Heffernan Sep 20 '19 at 10:30
  • 1
    The new Win10 virtual desktop feature is hard to use programmatically, Microsoft chose to intentionally not document the COM interfaces. A Russian programmer reverse-engineered it, you can see a C# version of it [here](https://stackoverflow.com/a/32417530/17034). Still not exactly what you want, no enumeration for windows, but you can enumerate desktops and switch to them so EnumWindows would see them. – Hans Passant Sep 20 '19 at 11:08

0 Answers0