Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''create a system tray icon that controls screen brightness using wmi'''
- from infi.systray import SysTrayIcon
- import wmi
- def bri_100(systray):
- '''brightness: 100%'''
- b = 100
- c = wmi.WMI(namespace='root\\wmi')
- br = c.WmiMonitorBrightnessMethods()[0]
- br.WmiSetBrightness(3, b) #b will be a precentage / 100
- def bri_75(systray):
- '''brightness: 75%'''
- b = 75
- c = wmi.WMI(namespace='root\\wmi')
- br = c.WmiMonitorBrightnessMethods()[0]
- br.WmiSetBrightness(3, b) #b will be a precentage / 100
- def bri_50(systray):
- '''brightness: 50%'''
- b = 50
- c = wmi.WMI(namespace='root\\wmi')
- br = c.WmiMonitorBrightnessMethods()[0]
- br.WmiSetBrightness(3, b) #b will be a precentage / 100
- def bri_25(systray):
- '''brightness 25%'''
- b = 25
- c = wmi.WMI(namespace='root\\wmi')
- br = c.WmiMonitorBrightnessMethods()[0]
- br.WmiSetBrightness(3, b) #b will be a precentage / 100
- def bri_0(systray):
- '''brightness: 0%'''
- b = 0
- c = wmi.WMI(namespace='root\\wmi')
- br = c.WmiMonitorBrightnessMethods()[0]
- br.WmiSetBrightness(3, b) #b will be a precentage / 100
- menu = (("brightness: 100%", None, bri_100),
- ("brightness: 75%", None, bri_75),
- ("brightness: 50%", None, bri_50),
- ("brightness: 25%", None, bri_25),
- ("brightness: 0%", None, bri_0))
- systray = SysTrayIcon("icon.ico", "brightness", menu)
- systray.start()
Add Comment
Please, Sign In to add comment