Page 1 of 1

IVirtualDesktopManager (Windows 10)

Posted: Sat Aug 03, 2019 6:57 am
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.

Re: IVirtualDesktopManager (Windows 10)

Posted: Sun Aug 18, 2019 9:02 pm
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)

Re: IVirtualDesktopManager (Windows 10)

Posted: Mon Aug 19, 2019 10:17 am
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?

Re: IVirtualDesktopManager (Windows 10)

Posted: Fri Aug 23, 2019 3:32 pm
by Kwai chang caine
In the two case the debugger say "Interface is ready!" with W10 X64 / v5.70 X86 :wink: