3

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.

Roberto
  • 31
  • 4
  • From what I can tell, the DM_SCALE field does not control the screen DPI. This question may be helpful https://stackoverflow.com/questions/35233182/how-can-i-change-windows-10-display-scaling-programmatically-using-c-sharp – Nick Kress Sep 19 '22 at 01:20

0 Answers0