简体   繁体   中英

How to get screen resolution from machine that has no screen?

I am trying to get the screen resolution of a headless machine that is running selenium tests.

Have already tried using System.Windows.Forms.Screen.PrimaryScreen as well as other options in Forms . I have tried using powershell and c#. Usually they tell me either the screen size after I RDP into the machine (which is just the size of the remote session) or the requests fail (if I try to get the size from a PSSession).

Thanks in advance!

You're on the right track, the screen class gives you the info you want:

$Screen = [system.windows.forms.screen]::AllScreens
"$($Screen.Bounds.Width) $($Screen.Bounds.Height)"

The answer to my issue turned out to be a hardware one and not a software one. I talked to my IT dept and they told me that they could change the resolution of VMs from their console for Nutanix. I had no idea that this was the issue.

Make sure to talk to your IT or VM admin if this is the case. This is the answer!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM