在Windows 10中,我们如何确定窗口所属的虚拟桌面?
发布时间:2020-07-22 15:36:20  所属栏目:Windows  来源:互联网 
            导读:关于 Windows 10及其新的虚拟桌面功能,有没有办法确定特定窗口属于哪个虚拟桌面?并且,哪个虚拟桌面处于活动状态? 使用截断工具可以看到问题.打开该工具,然后选择一个新建/窗口剪辑.当您移动鼠标时,剪切工具会突出显示没有窗口的区域,但在另一个虚拟桌面上的
                
                
                
            | 
                         关于 Windows 10及其新的虚拟桌面功能,有没有办法确定特定窗口属于哪个虚拟桌面?并且,哪个虚拟桌面处于活动状态? 使用截断工具可以看到问题.打开该工具,然后选择一个新建/窗口剪辑.当您移动鼠标时,剪切工具会突出显示没有窗口的区域,但在另一个虚拟桌面上的该位置有一个窗口. In this picture,the Snipping Tool is highlighting an empty spot. 截图工具不知道特定窗口所在的虚拟桌面. Here’s the same question on MSDN Forums,unanswered,but with lots of additional detail. 抱歉,我的状态不够高,无法插入图片或包含更多链接. Windows SDK Support Team Blog通过 IVirtualDesktopManager发布了 C# demo to switch Desktops:[ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown),Guid("a5cd92ff-29be-454c-8d04-d82879fb3f1b")]
[System.Security.SuppressUnmanagedCodeSecurity]
public interface IVirtualDesktopManager
{
[PreserveSig]
int IsWindowOnCurrentVirtualDesktop(
    [In] IntPtr TopLevelWindow,[Out] out int OnCurrentDesktop
    );
[PreserveSig]
int GetWindowDesktopId(
    [In] IntPtr TopLevelWindow,[Out] out Guid CurrentDesktop
    );
[PreserveSig]
int MoveWindowToDesktop(
    [In] IntPtr TopLevelWindow,[MarshalAs(UnmanagedType.LPStruct)]
    [In]Guid CurrentDesktop
    );
}
[ComImport,Guid("aa509086-5ca9-4c25-8f95-589d3c07b48a")]
public class CVirtualDesktopManager
{
}
public class VirtualDesktopManager
{
    public VirtualDesktopManager()
    {
        cmanager = new CVirtualDesktopManager();
        manager = (IVirtualDesktopManager)cmanager;
    }
    ~VirtualDesktopManager()
    {
        manager = null;
        cmanager = null;
    }
    private CVirtualDesktopManager cmanager = null;
    private IVirtualDesktopManager manager;
    public bool IsWindowOnCurrentVirtualDesktop(IntPtr TopLevelWindow)
    {
        int result;
        int hr;
        if ((hr = manager.IsWindowOnCurrentVirtualDesktop(TopLevelWindow,out result)) != 0)
        {
            Marshal.ThrowExceptionForHR(hr);
        }
        return result != 0;
    }
    public Guid GetWindowDesktopId(IntPtr TopLevelWindow)
    {
        Guid result;
        int hr;
        if ((hr = manager.GetWindowDesktopId(TopLevelWindow,out result)) != 0)
        {
            Marshal.ThrowExceptionForHR(hr);
        }
        return result;
    }
    public void MoveWindowToDesktop(IntPtr TopLevelWindow,Guid CurrentDesktop)
    {
        int hr;
        if ((hr = manager.MoveWindowToDesktop(TopLevelWindow,CurrentDesktop)) != 0)
        {
            Marshal.ThrowExceptionForHR(hr);
        }
    }
} 
 调用GetWindowDesktopId以获取桌面GUID. (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
推荐文章
            站长推荐
            - Windows/Linux命令查看文件MD5,SHA1,SHA256 文件
 - 用于类似Office 2013的Windows的Windows GUI库?
 - Windows环境下安装MySQL5.7及MySQL WrokBench
 - windows-mobile – Visual Studio 2010 Professi
 - windows自带应用xbox无法登陆:0x80070426:服务尚
 - 带有ANSI代码的文本编辑器/查看器,支持Windows
 - win10连接远程桌面,出现身份验证错误,要求的函
 - WIN10下安装 NGINX+PHP+MYSQL(WNMP) 环境
 - vs中dll调试的exe路径设置
 - SAP ECC6 SOLUTION MANAGER KEY 生成脚本 (VBS)
 
热点阅读
            