'How to change the windows resolution Scale with python?

I am trying to change the windows display configuration from python with the pywin32 library, I have managed to change the resolution but when trying to change the scale there are no changes or errors, my function is like this:

import win32api
import win32con
import pywintypes

def set_res(width, height):
    devmode = pywintypes.DEVMODEType()

    devmode.PelsWidth = width
    devmode.PelsHeight = height
    devmode.Scale = 125

    devmode.Fields = win32con.DM_PELSWIDTH | win32con.DM_PELSHEIGHT | win32con.DM_SCALE

    win32api.ChangeDisplaySettings(devmode, win32con.CDS_RESET)

As a result, the resolution is changed but the scale is not.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source