Windows 10 IVirtualDesktopManager::MoveWindowToDesktop

后端 未结 1 1639
清酒与你
清酒与你 2021-02-09 03:08

I\'ve been trying to use IVirtualDesktopManager::MoveWindowToDesktop to move windows between virtual desktops.

Using it on my own windows works great but unfortunately i

相关标签:
1条回答
  • 2021-02-09 03:57

    You can move a window not owned by the executing process, but it requires the use of additional, undocumented COM objects.

    1. Query ImmersiveShell for instances of IApplicationViewCollection and IVirtualDesktopManagerInternal.
    2. Get the hwnd of the window you want to move.
    3. It sounds like you already know the target desktop ID, but you can also use IVirtualDesktopManagerInternal methods GetAdjacentDesktop and GetDesktops to find more.
    4. Call IApplicationViewCollection::GetViewForHwnd to get the view.
    5. Call IVirtualDesktopManagerInternal::MoveViewToDesktop to move the view.

    Code references:

    • VirtualDesktopAccessor wraps the relevant objects in C++ and builds a native DLL you can use.
    • VirtualDesktop wraps them in C# and provides a .NET DLL and GUI.
    • zVirtualDesktop documents different versions of the interfaces.
    • This forum topic shows how to work with the IVirtualDesktopManagerInternal to select a virtual desktop by index in AutoHotKey. I'm working on a version that also wraps IApplicationViewCollection to support moving any given window as described above.
    0 讨论(0)
提交回复
热议问题