You can use the Windows Magnification API through the ctypes
library:
from ctypes import *
class RECT(Structure):
_fields_ = [('left', c_long),
('top', c_long),
('right', c_long),
('bottom', c_long)]
magnification_api = CDLL('magnification.dll')
# declare types
BOOL = c_bool
FLOAT = c_float
INT = c_int
LPRECT = LPRECT = POINTER(RECT)
PBOOL = PBOOL = POINTER(c_bool)
PMAGCOLOREFFECT = c_float * 25
MAGCOLOREFFECT = MAGCOLOREFFECT = POINTER(PMAGCOLOREFFECT)
# MagInitialize
magnification_api.MagInitialize.restype = BOOL
# MagUninitialize
magnification_api.MagUninitialize.restype = BOOL
# MagSetFullscreenColorEffect
magnification_api.MagSetFullscreenColorEffect.restype = BOOL
magnification_api.MagSetFullscreenColorEffect.argtypes = (MAGCOLOREFFECT,)
magnification_api.MagInitialize() # initialize the API
magnification_api.MagSetFullscreenColorEffect((c_float * 25)(-1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1)) # invert the screen
magnification_api.MagUninitialize() # use this to reset
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…