Skip to content

Instantly share code, notes, and snippets.

@hollobon
Created June 25, 2013 16:32
Show Gist options
  • Save hollobon/5859974 to your computer and use it in GitHub Desktop.
Save hollobon/5859974 to your computer and use it in GitHub Desktop.
Make an Emacs frame fullscreen (no caption or window borders) on Windows.
"""Make the Emacs window full-screen on Windows
At present, this will only adjust the first Emacs frame found. It could be modified to use
win32api.EnumWindows and win32api.GetClassName / win32api.GetWindowText in order to adjust all
Emacs frames.
"""
import argparse
import sys
import win32gui
import win32con
def set_borderless(hwnd, off=False):
"""Turn off / on titlebar and border"""
borderless_style = (win32con.WS_BORDER | win32con.WS_THICKFRAME
| win32con.WS_CAPTION | win32con.WS_MAXIMIZE)
current_style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
if off:
style = current_style | borderless_style
else:
style = current_style & ~borderless_style
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--off", action="store_true", help="Turn off full-screen mode")
args = parser.parse_args()
# Find first Window with class of "Emacs"
emacs_hwnd = win32gui.FindWindowEx(None, None, "Emacs", None)
if not emacs_hwnd:
print("No Emacs window found")
return 1
set_borderless(emacs_hwnd, args.off)
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment