How to get Windows screen size?

Hello Everyone,

How to get windows screen size after zoom in
screen.primaryscreen gives total height and width eg.,(1920*1080) but how can we get screen size after zoom into 125% or 150%

This is 100% working . area is 1920*1080

when zoomed in to 150%


1270-665 for 150% - but the workingarea sysntax result is 1920-1040

How to get only visible screen size coordinates


I think the resolution will not change if you change the size of the texts , apps and other things.


The property “WorkingArea” is used to get the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

HeightValue = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height.ToString
WidthValue = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width.ToString

If you want to get the resolution, you can use the property “Bounds”.

HeightValue = Screen.PrimaryScreen.Bounds.Height.ToString
WidthValue = Screen.PrimaryScreen.Bounds.Width.ToString

Or you can use this PowerShell script for more accurate details:

# Get display details: display count, display Height and Width, Scale DPI, Bits per pixel

 Add-Type -AssemblyName System.Windows.Forms
 $screen_cnt  = [System.Windows.Forms.Screen]::AllScreens.Count
 $col_screens = [System.Windows.Forms.Screen]::AllScreens
 $rh=[int](Get-CimInstance -ClassName Win32_VideoController)[0].CurrentVerticalResolution

 Write-Host "TOTAL SCREEN COUNT: $screen_cnt  `n"
  $info_screens = ($col_screens | ForEach-Object {
 if ("$($_.Primary)" -eq "True") {$monitor_type = "Primary Monitor    "} else {$monitor_type = "Secondary Monitor  "}
 if ("$($_.Bounds.Width)" -gt "$($_.Bounds.Height)") {$monitor_orientation = "Landscape"} else {$monitor_orientation = "Portrait"}
 Write-Host $monitor_type  "(Bounds)                                $($_.Bounds)"
 Write-Host $monitor_type  "(Primary)                               $($_.Primary)"
 Write-Host $monitor_type  "(Device Name)                           $($_.DeviceName)"
 if(([int]$_.Bounds.Width -ge 1024) -and ([int]$_.Bounds.Height -ge 768)){
 Write-Host $monitor_type  "(ResolutionWidth x ResolutionHeight)    $($_.Bounds.Width) x $($_.Bounds.Height) ($monitor_orientation)" -ForegroundColor green
 if(([int]$_.Bounds.Width -lt 1024) -and ([int]$_.Bounds.Height -lt 768)){
 Write-Warning "Resolutions below 1024x768 are not supported. Running Studio on such displays causes the Studio Backstage view to be displayed incorrectly."
 Write-Host $monitor_type  "(ResolutionWidth x ResolutionHeight)    $($_.Bounds.Width) x $($_.Bounds.Height) ($monitor_orientation)" -ForegroundColor red
 Write-Host $monitor_type  "(ResolutionDepth)                       $($_.BitsPerPixel)"
 if($screen_scale_factor -ne 100){
 Write-Warning "Your display scale is not 100%. This may impact your UiAutomation projects. In some cases you may have errors such as: 'Cannot send input to UI element because it is outside of screen bounds', 'Timeout reached', and many more."
 Write-Host $monitor_type  "(Scale DPI)                             $screen_scale_factor%" -ForegroundColor yellow
 if($screen_scale_factor -eq 100){
 Write-Host $monitor_type  "(Scale DPI)                             $screen_scale_factor%" -ForegroundColor green
 Write-Host $monitor_type  "(Working Area)                          $($_.WorkingArea) `n"
 Write-Host "----------------------------------------------------------------------------------------------------------------------------`n"


1 Like


Import the namespace System.Windows.Forms & try you will get

you can just use the entire line like:


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.