问题描述
在 Python 中,如何使用 ctypes 模块在不使用键盘快捷键的情况下在 Windows PC 上反转整个屏幕?
我注意到可以使用 Windows Magnification API,但它是为 C 设计的。使用 ctypes,我可以与 DLL 交互,并反转屏幕。我可以初始化它:
Text {
id: text1
x: 63
y: 68
text: mqttClient.message
font.pixelSize: 12
}
如何使用 API 来反转屏幕?
解决方法
您可以通过 from ctypes import *
class RECT(Structure):
_fields_ = [('left',c_long),('top',('right',('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)
# MagInitialize
magnification_api.MagInitialize.restype = BOOL
# MagUninitialize
magnification_api.MagUninitialize.restype = BOOL
magnification_api.MagInitialize() # initialize the API
magnification_api.MagUninitialize() # uninitialize
库使用 Windows Magnification API:
ctypes