我正在寻找一种从命令 shell 获取和设置窗口的位置和大小的方法。
然而我只能找到如何使用 PowerShell 来做到这一点:
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Window {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
}
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
"@
$Handle = (Get-Process -Id $Args[0]).MainWindowHandle
$WindowRect = New-Object RECT
$GotWindowRect = [Window]::GetWindowRect($Handle, [ref]$WindowRect)
ConvertTo-Json($WindowRect)
在(非 powershell)命令行中是否有执行此操作的等效程序?