我一直试图使我的脚本在多个屏幕尺寸上均匀显示,而不必手动输入分辨率。我不想每次在其他设备上运行脚本时都不必编辑脚本。预先感谢您的回答,我们将不胜感激。到目前为止,这就是我所拥有的...
#Main Form creation
$mainForm = makeForm -formWindowState "Maximized" -formClientSize "1920,1080"
-formText "Removable Media"
答案 0 :(得分:0)
您可以使用WMI类Win32_VideoController
获取监视器分辨率:
PS > Get-WmiObject -class "Win32_VideoController" | select CurrentHorizontalResolution,CurrentVerticalResolution
CurrentHorizontalResolution CurrentVerticalResolution
--------------------------- -------------------------
1920 1080
并使用以下值设置表单大小:
$vc = Get-WmiObject -class "Win32_VideoController"
$mainForm = makeForm -formWindowState "Maximized" -formClientSize "$($vc.CurrentHorizontalResolution),$($vc.CurrentVerticalResolution)" -formText "Removable Media"
答案 1 :(得分:0)
您还可以通过Windows.Forms.Cursor
类获取屏幕尺寸信息
[Windows.Forms.Cursor]::Clip | Select-Object Width, Height