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
Revision as of 13:50, 12 September 2024 by Derg (talk | contribs) (Derg moved page Displaytoggle.py to displaytoggle.py without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
#!/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)