相关疑难解决方法(0)

在 PowerShell 5 和 6 中设置窗口大小和位置

问题:我们有一台用于演示的大电视,它不完全是 1920×1080 像素。它关闭了,我无法控制它。我可以控制的是我连接到它的 Windows 笔记本电脑。我一直在寻找方法来显示我需要的任何内容,移动到投影仪,设置一个偏移位置以在电视上看起来不错,并设置相同的宽度/高度。

做了什么:我可以使用 Boe Prox 的 Get-Window 脚本(https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/26/weekend-scripter-manage-window-placement-by-using-pinvoke/ ),而且效果很好,可以为我提供所需的尺寸和偏移量。但是,无论有没有管理员权限,他在 WinPosh 5 和 Posh 6 中都出现了我的设置窗口错误。其他潜在的解决方案产生了类似的错误,所以我决定继续使用 Prox 的脚本,因为按照我的标准,他是专家。

我正在评估这里提到的解决方案, /sf/ask/727483431/ -window/作为可能的解决方法。但是,不依赖任何第三方的 PowerShell 解决方案将是理想的。

问题是: 有没有人解决了如何在直接 v5 或 v6 PowerShell 中获取 Prox 先生的设置窗口或其他任何设置窗口位置和大小的方法?

Posh 5 中的错误消息:

Cannot convert argument "hWnd", with value: "System.Object[]", for "GetWindowRect" to type "System.IntPtr": "Cannot
convert the "System.Object[]" value of type "System.Object[]" to type "System.IntPtr"."
At Z:\scripts\Set-Window.ps1:90 char:9
+         $Return = [Window]::GetWindowRect($Handle,[ref]$Rectangle)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-5.0

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

powershell ×1

powershell-5.0 ×1