Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get screen DPI

import ctypes
import win32api

PROCESS_PER_MONITOR_DPI_AWARE = 2
MDT_EFFECTIVE_DPI = 0

def print_dpi():
    shcore = ctypes.windll.shcore
    monitors = win32api.EnumDisplayMonitors()
    hresult = shcore.SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)
    assert hresult == 0
    dpiX = ctypes.c_uint()
    dpiY = ctypes.c_uint()
    for i, monitor in enumerate(monitors):
        shcore.GetDpiForMonitor(
            monitor[0].handle,
            MDT_EFFECTIVE_DPI,
            ctypes.byref(dpiX),
            ctypes.byref(dpiY)
        )
        print(
            f"Monitor {i} (hmonitor: {monitor[0]}) = dpiX: {dpiX.value}, dpiY: {dpiY.value}"
        )


if __name__ == "__main__":
    print_dpi()
Comment

PREVIOUS NEXT
Code Example
Python :: python array to text 
Python :: images in pygame 
Python :: check if variable is iterable python 
Python :: reveal a defined function in python 
Python :: django command to fetch all columns of a table 
Python :: preventing players from changing existing entries in tic tac toe game 
Python :: how to delete lists after using them in python 
Python :: python dash bootstrap buttons with icons 
Python :: western school district 
Python :: how to install pandas in python by git 
Python :: readline python sin avanzar de linea 
Python :: pytesseract.image_to_data into pandas dataframe 
Python :: rotate an image python keras 
Python :: matlab end of array 
Python :: python code to display a grid of data table 
Python :: can data scientists become software developer 
Python :: python convert unicode escape sequence 
Python :: mo.group() separated with spaces instead of commas python 
Python :: flask pass an array of dicts 
Python :: pip set mirror site 
Python :: repeating a program in python 
Python :: Delete file to trash 
Python :: Fill specific area under curve 
Python :: Compute p-value 
Python :: telegram bot python 
Python :: threshold image segmentation code python 
Python :: debug forbidden by robots.txt scrappy 
Python :: critical errors python 
Python :: trivia python game 
Python :: create empty dataframe and concat 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =