I just wrote a simple PowerShell script to get the screen resolution of my monitor, but it seems to be returning the wrong values.
# Returns an screen width and screen height of maximum screen resolution
function Get-ScreenSize {
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$width = $screen.Bounds.Width
$height = $screen.Bounds.Height
return $width, $height
}
Get-ScreenSize
I am running this script on a 4k monitor with the resolution set at 3840 x 2160, but it is giving me the following output:
1536
864
Is there anything that would cause System.Windows.Forms.Screen to get the wrong "Bounds" values?
Boundsuses the virtual screen size (not entirely sure, why the numbers are smaller than expected, though), whileWorkingAreauses the multi-monitor API. I don't know how to fix the PowerShell commandlet, though.