Fix number of monitors found (#42/#43/#51)

- I used my laptop connected to a HDMI TV to solve this issue (The GUI was HUUUUGE)
- On multi-monitor system, to get the GUI normal, the system layout scale should be 100%, not more than this
main
Plínio Larrubia 2 years ago committed by Plínio Larrubia
parent 5fd400b3f5
commit 77685da252
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -14,13 +14,18 @@ function Get-CurrentResolution {
[OutputType([System.Object[]])]
param ()
$NumberOfScreens = (Get-CimInstance -Class "Win32_VideoController" | ForEach-Object { "$_" }).Count
# Adapted from: https://www.reddit.com/r/PowerShell/comments/67no9x/comment/dgrry3b/?utm_source=share&utm_medium=web2x&context=3
$NumberOfScreens = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Where-Object { $_.Active -like "True" }).Active.Count
$ScreenWidth = $null
$ScreenHeight = $null
Write-Verbose "Num. of Monitors: $NumberOfScreens"
If ($NumberOfScreens -eq 1) {
# Accepts Scaling/DPI
[System.Windows.Forms.SystemInformation]::VirtualScreen | ForEach-Object {
Write-Verbose "W: $($_.Width) | H: $($_.Height)"
If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.Width
$ScreenHeight = $_.Height
@ -34,6 +39,8 @@ function Get-CurrentResolution {
} Else {
# Doesn't accepts Scaling/DPI (rollback method)
Get-CimInstance -Class "Win32_VideoController" | ForEach-Object {
Write-Verbose "W: $($_.CurrentHorizontalResolution) | H: $($_.CurrentVerticalResolution)"
If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.CurrentHorizontalResolution
$ScreenHeight = $_.CurrentVerticalResolution

Loading…
Cancel
Save