Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

displaytoggle.py

From Randomness wiki
#!/usr/bin/python3
import win32api, win32con, argparse

screenid = 1

a = argparse.ArgumentParser()
a.add_argument('on', nargs="?", default=False, type=lambda x: x.lower() not in ("false", "0", "off"))
b = a.parse_args()

screenstring = f"\\\\.\\DISPLAY{screenid:d}"

if b.on:
    win32api.ChangeDisplaySettingsEx(screenstring, None)
else:
    s = win32api.EnumDisplaySettings(screenstring, win32con.ENUM_CURRENT_SETTINGS)
    s.PelsWidth = 0
    s.PelsHeight = 0
    win32api.ChangeDisplaySettingsEx(screenstring, s)