IVirtualDesktopManager (Windows 10)

Windows specific forum
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

IVirtualDesktopManager (Windows 10)

Post by Rinzwind »

Any way to use this interface from PB?

https://docs.microsoft.com/en-us/window ... topmanager

The IVirtualDesktopManager interface has these methods.

Method Description
IVirtualDesktopManager::GetWindowDesktopId Gets the identifier for the virtual desktop hosting the provided top-level window.
IVirtualDesktopManager::IsWindowOnCurrentVirtualDesktop Indicates whether the provided window is on the currently active virtual desktop.
IVirtualDesktopManager::MoveWindowToDesktop Moves a window to the specified virtual desktop.

The API is incomplete IMHO (missing enumeration for example). You wonder why MS started from scratch instead of improving the existing flat win32 virtual desktop API... but whatever.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: IVirtualDesktopManager (Windows 10)

Post by Mijikai »

I came up with this:

Code: Select all

EnableExplicit

Interface IVirtualDesktopManager
  IsWindowOnCurrentVirtualDesktop.i(*topLevelWindow)
  GetWindowDesktopId.i(*topLevelWindow)
  MoveWindowToDesktop.i(*topLevelWindow,*desktopId)
EndInterface

Procedure.i GetIVirtualDesktopManager()
  Protected cid.CLSID
  Protected iid.CLSID
  Protected vtable.i
  If CoInitialize_(#Null) = #S_OK
    If CLSIDFromString_("{AA509086-5CA9-4C25-8F95-589D3C07B48A}",@cid) = #S_OK
      If IIDFromString_("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}",@iid) = #S_OK
        If CoCreateInstance_(@cid,#Null,#CLSCTX_INPROC_SERVER,@iid,@vtable) = #S_OK
          ProcedureReturn vtable  
        EndIf 
      EndIf 
    EndIf
    CoUninitialize_()
  EndIf
  ProcedureReturn #Null
EndProcedure

Global *VirtualDesktopManager.IVirtualDesktopManager

*VirtualDesktopManager = GetIVirtualDesktopManager()

If *VirtualDesktopManager
  Debug "Interface is ready!"  
Else
  Debug "Error!"
EndIf

End
Not sure if it works (i have no Windows 10 right now)
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: IVirtualDesktopManager (Windows 10)

Post by Mijikai »

Ok now i was able to run it on Windows 10

The interface gets created but it may look different:

Code: Select all

Interface IVirtualDesktopManager
  IsWindowOnCurrentVirtualDesktop.i(topLevelWindow.i,*onCurrentDesktop.b)
  GetWindowDesktopId.i(topLevelWindow.i,*desktopId)
  MoveWindowToDesktop.i(topLevelWindow.i,*desktopId)
EndInterface
Does this work?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: IVirtualDesktopManager (Windows 10)

Post by Kwai chang caine »

In the two case the debugger say "Interface is ready!" with W10 X64 / v5.70 X86 :wink:
ImageThe happiness is a road...
Not a destination
Post Reply