UiPath parameters fetching different Resolution values than actual

Hi @UiPath_Community,

Have you ever come across below scenario?

My laptop screen resolution comes as 1920*1080 when I go to Display settings of my laptop and check the resolution.
Below screenshot for same:

However, when I try to fetch resolution values using UiPath parameters as below, it is showing as 1280*720, I wonder why?
"The primary screen resolution is: " + System.Windows.SystemParameters.PrimaryScreenWidth.ToString + " x " + System.Windows.SystemParameters.PrimaryScreenHeight.ToString

Even when i checked the screenshots taken for my process while running, those also showing resolutions as 1920*1080.

But it seems like UiPath is picking different values which is why when I try to run this process on VM, it doesn’t run successfully on default values (1920 and 1080) but when I tried changing the values to (1280 and 720), it ran successfully.

What do you think can be the reason for this difference in values?

Regards
Sonali

I have never specifically tested, but doesn’t it work correctly, if you set it to 100% with 1080p?

@sonaliaggarwal47

To check try using

System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width

Which gives width similarly use height

Cheers

Hi @Anil_G,

yes when I used the below parameters shared by you, resolution printed is 1920*1080 exactly as my actual laptop screen resolution. (result shown in the screenshot below in 2nd line)

"Resolution value check: “+System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString+” by "+System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString

But using below parameters for the same process, gives me resolution as 1280*720. (result shown in the screenshot below in 1st line)
"The primary screen resolution is: " + System.Windows.SystemParameters.PrimaryScreenWidth.ToString + " x " + System.Windows.SystemParameters.PrimaryScreenHeight.ToString

PFB screenshot of the log message from output panel of studio, 2nd message is from the parameters mentioned at the top of this email:

image

No idea why this difference, however, I do understand from the process behavior on VM that the process works fine on VM if resolution is set as the one provided by below parameters.
System.Windows.SystemParameters.PrimaryScreenWidth.ToString
System.Windows.SystemParameters.PrimaryScreenHeight.ToString
which makes me believe that it is the right set of parameters to identify the screen resolution on which process was developed.

But why this difference in resolution values, I have no idea, may be @codemonkee can shed some light on this.

Regards
Sonali

Hi @iamNairda,

Thanks for your reply.

I tested the resolution values for process after setting the percentage to 100% and it did give me result as 1920*1080.

Please see below screenshot:

image

1st set of values in screenshot given by below parameters:
System.Windows.SystemParameters.PrimaryScreenWidth.ToString + " x " + System.Windows.SystemParameters.PrimaryScreenHeight.ToString

and 2nd set of values given by below:
“+System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString+” by "+System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString

This makes me think may be we need to change our resolution to 100% first during development if we want to develop the process on by-default resolution pick for our VMs which comes by 19201080. The reason I say default resolution for our VMs, when I tried printing resolution of VM in unattended mode(with no change in login console(yes) or resolution(0,0,0)), it was picked as 19201080, so I considered that our VMs are on this resolution or may be the resolution picked in this case was the one that was set by the last process that ran on this VM?

What do you think?

Regards
Sonali

This is why.

[PrimaryScreenHeight] Gets a value that indicates the screen height, in pixels adjusted for DPI, of the primary display monitor.

[PrimaryScreenWidth] Gets a value that indicates the screen width, in pixels adjusted for DPI, of the primary display monitor.

You should be using System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/Height

Hi @marian.platonov @ClaytonM,

Requesting your inputs as well on this.

Regards
Sonali

Hi,

We have done some testing on the topic and have found below:

To get the resolution being picked by bot, below parameters need to be used:
System.Windows.SystemParameters.PrimaryScreenWidth.ToString System.Windows.SystemParameters.PrimaryScreenHeight.ToString

Below parameters only tell the resolution defined in display setting. but that may not be the one being picked up by bot as percentage defined can lead to varying resolutions.
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString

Regards
Sonali

I don’t agree.

The robot will be similarly affected by any zoom settings on their user profile.

I believe Paul explained / linked why there is a difference here.

The SystemParamters one will get the underlying resolution, and the Forms will get the displayed resolution.

Clearly what seems to be happening is, when zoomed, the forms shows the ones you see it as, and the systemparamters does it effectively at 100% and so less resolution.

The only one that matters is the Forms one, which in my experience is always the standard (not sure why you are using the other one). As zoomed or not, this will display the effective resolution.

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