Windows 10及以上系统下在指定显示器打开应用的可行方案问询(支持快捷方式、命令行、快捷键)
Windows 10及以上系统下在指定显示器打开应用的可行方案问询(支持快捷方式、命令行、快捷键)
嘿,我刚好踩过类似的坑,给你整理几个Win10及以上系统亲测有效的方案,完全能满足你要的「快捷方式/命令行/快捷键启动到指定显示器」的需求,还能解决你遇到的那种卡死置顶窗口的紧急情况:
MultiMonitorTool 免费第三方工具方案
这是一款专门针对多显示器场景的免费小工具,完美支持Win10和Win11,完全不依赖保存的窗口位置(再也不用担心显示器断开后设置失效):- 命令行调用:直接用指定参数启动应用到目标显示器,比如要在显示器2打开任务管理器,命令是:
MultiMonitorTool.exe /Run "taskmgr.exe" 2 - 快捷方式与快捷键:把上面的命令做成桌面快捷方式,右键打开「属性」,在「快捷键」栏设置你想要的组合键(比如Ctrl+Shift+Alt+Esc),以后按这个快捷键就能直接在指定显示器打开任务管理器。
特别适合你遇到的那种场景:显示器1有卡死的置顶窗口时,用这个快捷键启动任务管理器到显示器2,完全不会被置顶窗口抢焦点,直接就能操作杀进程。
- 命令行调用:直接用指定参数启动应用到目标显示器,比如要在显示器2打开任务管理器,命令是:
PowerShell 无第三方工具方案
如果你不想装任何工具,也可以用PowerShell脚本实现,原理是启动应用后立刻调用系统API把窗口移到指定显示器:- 把下面的代码保存为
Start-AppOnMonitor.ps1文件:
param( [string]$AppPath, [int]$MonitorNumber = 1 ) $process = Start-Process -FilePath $AppPath -PassThru Start-Sleep -Milliseconds 500 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 GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi); [DllImport("user32.dll")] public static extern IntPtr MonitorFromWindow(IntPtr hWnd, uint dwFlags); public struct MONITORINFO { public int cbSize; public RECT rcMonitor; public RECT rcWork; public uint dwFlags; } public struct RECT { public int Left; public int Top; public int Right; public int Bottom; } } "@ $hWnd = $process.MainWindowHandle while ($hWnd -eq [IntPtr]::Zero) { Start-Sleep -Milliseconds 100 $process.Refresh() $hWnd = $process.MainWindowHandle } $monitorInfo = New-Object Win32+MONITORINFO $monitorInfo.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($monitorInfo) $hMonitor = [Win32]::MonitorFromWindow($hWnd, 0x00000002) [Win32]::GetMonitorInfo($hMonitor, [ref]$monitorInfo) $x = ($MonitorNumber - 1) * $monitorInfo.rcMonitor.Right [Win32]::MoveWindow($hWnd, $x, 0, $monitorInfo.rcMonitor.Right, $monitorInfo.rcMonitor.Bottom, $true)- 命令行调用:用下面的命令启动应用到指定显示器(比如显示器2打开命令提示符):
powershell.exe -ExecutionPolicy Bypass -File Start-AppOnMonitor.ps1 -AppPath "cmd.exe" -MonitorNumber 2 - 同样可以把这个命令做成快捷方式,设置专属快捷键,实现一键启动。
不过这个方案需要稍微调整脚本里的Start-Sleep时长(如果应用启动较慢的话),灵活性不如第三方工具。
- 把下面的代码保存为
补充说明
关于Windows 11网传的内置方案,亲测在部分版本中不稳定,而且你需要Win10及以上的通用方案,上面两个方案完全覆盖需求,不用依赖那些不确定的内置功能。
备注:内容来源于stack exchange,提问作者Estus Flask
相关产品推荐
相关产品推荐

