Windows 10 IVirtualDesktopManager::MoveWindowToDesktop [英] Windows 10 IVirtualDesktopManager::MoveWindowToDesktop

查看:50
本文介绍了Windows 10 IVirtualDesktopManager::MoveWindowToDesktop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 IVirtualDesktopManager::MoveWindowToDesktop 在虚拟桌面之间移动窗口.

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

在我自己的窗口上使用它效果很好,但不幸的是,当我尝试在另一个进程的窗口上使用它时,它以 E_ACCESSDENIED 失败.

Using it on my own windows works great but unfortunately it fails with E_ACCESSDENIED when I try to use it on the window of another process.

遗憾的是,以管理员身份启动"还不够好.我是否遗漏了一些我不了解 COM 接口的内容,或者只是设计不当?

Sadly "Launch as admin" is not good enough for it. Am I missing something that I don't know about COM interfaces or is it just badly designed ?

推荐答案

您可以移动不属于执行进程的窗口,但它需要使用额外的、未记录的 COM 对象.

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

  1. 查询 ImmersiveShell 以获取 IApplicationViewCollection 和 IVirtualDesktopManagerInternal 的实例.
  2. 获取要移动的窗口的 hwnd.
  3. 听起来您已经知道目标桌面 ID,但您也可以使用 IVirtualDesktopManagerInternal 方法 GetAdjacentDesktop 和 GetDesktops 来查找更多信息.
  4. 调用 IApplicationViewCollection::GetViewForHwnd 以获取视图.
  5. 调用 IVirtualDesktopManagerInternal::MoveViewToDesktop 来移动视图.

代码参考:

  • VirtualDesktopAccessor 用 C++ 包装相关对象并构建一个您可以使用的本机 DLL.
  • VirtualDesktop 将它们封装在 C# 中并提供了 .NET DLL 和 GUI.
  • zVirtualDesktop 记录了不同版本的界面.
  • 这个论坛主题展示了如何使用IVirtualDesktopManagerInternal 通过 AutoHotKey 中的索引选择虚拟桌面.我正在开发一个还包装 IApplicationViewCollection 以支持移动上述任何给定窗口的版本.
  • 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.

这篇关于Windows 10 IVirtualDesktopManager::MoveWindowToDesktop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆