You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何配置Windows 11实现断开外接显示器时自动将所有窗口移回主显示器?

如何配置Windows 11实现断开外接显示器时自动将所有窗口移回主显示器?

我太懂这种每次切换显示器都要手动拖窗口的麻烦了!下面给你几个切实可行的方案,从系统自带调整到第三方工具,总有一个适合你:

一、试试Windows 11自带的注册表调整(部分设备生效)

有些用户反馈修改注册表能开启自动移窗功能,步骤如下:

  1. 按下Win+R打开“运行”窗口,输入regedit回车打开注册表编辑器
  2. 导航到路径:HKEY_CURRENT_USER\Control Panel\Desktop
  3. 若右侧没有MonitorOverride项,右键新建字符串值并命名为MonitorOverride
  4. 将它的数值数据设置为1
  5. 重启电脑后,断开外接显示器时,系统大概率会自动把外接屏上的窗口移到主显示器

不过这个方法受显卡驱动和系统版本影响,要是没效果就试试下面的方案。

二、用第三方工具实现智能管理(推荐)

第三方工具在多显示器窗口管理上更靠谱,免费版就能满足需求:

  • DisplayFusion:安装后进入“显示器配置”界面,找到“显示器断开”相关设置,勾选“将窗口移到主显示器”选项,还能自定义特定程序的窗口位置,适配你在家和办公室的不同场景
  • Actual Window Manager:同样支持断开显示器时自动移窗,还能设置窗口记忆、分屏布局等进阶功能,按需选择即可

三、手动批量移动窗口的快捷方法

要是不想装软件,也可以用快捷命令或脚本快速整理窗口:

  • PowerShell批量移动:打开管理员权限的PowerShell,输入以下命令(记得把分辨率改成你的主显示器参数):
    Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    public class Win32 {
        [DllImport("user32.dll")]
        public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
        [DllImport("user32.dll")]
        public static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
        public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
        [DllImport("user32.dll")]
        public static extern bool IsWindowVisible(IntPtr hWnd);
    }
    "@
    $proc = {
        param($hWnd, $lParam)
        if ([Win32]::IsWindowVisible($hWnd)) {
            [Win32]::MoveWindow($hWnd, 0, 0, 1920, 1080, $true) # 替换成你的主显示器分辨率
        }
        return $true
    }
    [Win32]::EnumWindows($proc, [IntPtr]::Zero)
    
    执行后所有可见窗口都会移到主显示器左上角。
  • AutoHotkey快捷脚本:写个简单脚本绑定快捷键,比如Ctrl+Alt+M触发批量移动:
    ^!M:: ; Ctrl+Alt+M 为触发快捷键
    WinGet, WindowList, List
    Loop, %WindowList%
    {
        WinMove, ahk_id %WindowList%A_Index,, 0, 0 ; 移到主显示器左上角
    }
    return
    

备注:内容来源于stack exchange,提问作者Roddy of the Frozen Peas

火山引擎 最新活动