Virtual Desktop Properties To Command Line

Is there a way from the command line (wmic, regedit, or dedicated tool) to check how many Virtual Desktops in Windows 10 are active, in which a window is, and which one the computer is currently using?


Solution 1:

Use the IVirtualDesktopManager interface to construct a (command line) application to monitor the current status of virtual desktop windows.

Virtual Desktop Switching in Windows 10 (Windows SDK Support Team Blog)

IVirtualDesktopManager

To go along with the addition of virtual desktops in Windows 10, a new shell interface was introduced called IVirtualDesktopManager. It only has three functions, but those allow you to do many things with virtual desktops and your own application.

IsWindowOnCurrentVirtualDesktop will tell you if your window is on the current virtual desktop. GetWindowDesktopId will give you the ID of the desktop the specified window is on. MoveWindowToDesktop will allow you to move a specified window to a specified desktop.


How many Virtual Desktops are active:

Comments:
Chris Lewis [MSFT]: There unfortunately is not an API to enumerate virtual desktops at this time.

In which a window is

GetWindowDesktopId will give you the ID of the desktop the specified window is on.

Which one the computer is currently using

If you create a new window with no parent, it will be placed on the current virtual desktop. [Call GetWindowDesktopId to get the desktop ID for the new window.]

Solution 2:

Call AutoHotkey scripts from the command line (or batch file) to send keyboard presses for Virtual Desktop shortcut keys.