Setting resolution programatically

RPA_1

Member
I need to ensure that wherever the process runs that is across different environment , vdi etc. I do not encounter any issues with respect to resolution change ( I cannot be sure what resolution the vdi is in). That is something which is not fixed. How to make sure that resolution is set to some desired value when bot logins into a vdi to execute a process.
Code stage should be helpful.
 

VJR

Well-Known Member
Hi RPA_1,

I haven't done this through BP but have done it manually and is working fine and I believe the same can be achieved through BP as explained below.

I have used the instructions from the below link...
https://github.com/juanitogan/rbxit/wiki/Display-resolution-shortcuts

...to create the below steps.
i. First create a SetRes.ps1 as per the instructions in the above link

ii. Then created two batch files one with each resolution that I want eg; 1024x768.bat and 1366x768.bat
The content of these .bat files should be only this 1 line depending on what resolution you want in each file (in red color).

PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%CD%\SetRes.ps1" 1024 768

iii. Now I have 3 files. All the files need to be in the same folder. Refer attached screenshot

iv. I need not touch the .ps1 file now. I manually first ran the 1024x768.bat by double clicking it. It changed the screen resolution to 1024x768 and then ran the 1366x768 which again changed the resolution to 1366x768

v. The same can be done by running the batch files from BP. Refer below link-
http://www.rpaforum.net/threads/launch-bat-file-from-blue-prism.602/

vi. Before running the above commands through BP you may want to use the 'Get Screen Resolution' action of 'Utility - Environment' and change the resolution only if required.

vii. Also go through the caveats mentioned on this link.
https://github.com/juanitogan/rbxit/wiki/Display-resolution-shortcuts


I assume you are using Windows and Powershell is integrated within Windows, which is similar to, but more powerful than Command Prompt. You can check by typing "powershell" in the Run command and hit enter. This should open the Powershell.
 

Attachments

  • Batchfile change screen resolution.JPG
    Batchfile change screen resolution.JPG
    13.9 KB · Views: 173
Last edited:

RPA_1

Member
Thanks for he detailed log. Would try this . Though I can manually change the resolution directly from control panel setting by logging into vdi or target machine. What I am working on is a simple code stage which ensure that my resolution is set to the desired one whenever a process is invoked on any vdi (this should be dynamic).
In this way my solution will be robust enough to avaoid any resolution related issues failing the process.
As of now no inbuilt functionality can handle this other than code stage using vb.net or C# coding. We only have get resolution option as pointed out from your end as well ...
 

VJR

Well-Known Member
Hi RPA_1,

You will find lots of code over the internet to change the resolution in the 3 languages supported by BP ie; Vb, C# and J# which can be added to the BP Code stage. But they are not straight forward and not guaranteed to run because those Code uses APIs and some advanced programming and the BP Code stage is limited.

You will be able to achieve what you are trying to achieve. You want a single stage to change the resolution and that too dynamic. So you just need one stage that will use the Start process to run that 1 batch file having the desired resolution. The two batch files that I showed in the screenshot was just an example to demonstrate. You will only need 1 .bat file having the desired resolution. There is only a one time activity of placing the required .bat and the ps1 file on the destination machines.

Do let us know whatever solution you come up with.

Cheers.
 

Ismael

New Member
I confirm, I used this approach and it's a simple and quick solution!!

It works very good.

Thanks a lot VJR.
 
  • Like
Reactions: VJR
Top