How to change screen resolution using UFT
Automation tools are equipped with so many capabilities. Though not directly, but with a workaround UFT/QTP supports changing screen resolution. This can be achieved with the help of a small dll file and DotNetFactory object of UFT.
before we go ahead to see how to do this, we need to understand two important things which is required by this solutions.
- What is DLL? A DLL is a library that contains code and data that can be used by more than one program at the same time. In other words, it is the function library of windows.
- What is DotNetFactory? DotNetFactory is an object in UFT, which enables UFT scripts to access methods and properties of a .NET object by creating an instance of this object. This is utilised by our solution.
In order to change screen resolution, the solution is of two parts. We need to follow below steps.
- Write a dll file using C#. (given below)
- Call the above created dll file in CreateInstance function of DotNetFactory object.
C# code to write the DLL file
How to call the DLL in UFT script
As you can see in the program above, first we have created a dll using C# and then we have called the dll in our UFT script using DotNetFactory object. Now we can parse the arguments as int width,int height ,int frequency ,int BitsPerPel
Parameters representing the width, height, refresh rate and, color quality
Checkout the code repo
more code ?