import ctypes
import os


def enablePerMonitorAwareness():
    """Use physical pixels for Windows display, window, and mouse coordinates."""
    if os.name != 'nt':
        return False
    try:
        user32 = ctypes.WinDLL('user32', use_last_error=True)
        context = user32.SetProcessDpiAwarenessContext
        context.argtypes = [ctypes.c_void_p]
        context.restype = ctypes.c_bool
        if context(ctypes.c_void_p(-4)):  # PER_MONITOR_AWARE_V2
            return True
    except (AttributeError, OSError):
        pass
    try:
        shcore = ctypes.WinDLL('shcore', use_last_error=True)
        return shcore.SetProcessDpiAwareness(2) == 0  # PROCESS_PER_MONITOR_DPI_AWARE
    except (AttributeError, OSError):
        return False
