Pycharm利用wmi调整windows屏幕亮度

Pycharm利用wmi调整windows屏幕亮度

首先安装好wmi,终端直接输入:pip install wmi回车即可
代码:

import wmi


#调整屏幕亮度
def ScreenChange(percent):#percent/2即为亮度百分比
    SCREEN = wmi.WMI(namespace='root\WMI')
    a = SCREEN.WmiMonitorBrightnessMethods()[0]
    a.WmiSetBrightness(Brightness=percent, Timeout=500)


ScreenChange(100)

放在自己的项目中让别人也体验一下屏幕忽明忽暗的感觉吧

你可能感兴趣的:(python,前端,python)