Created
June 11, 2018 21:10
-
-
Save goraj/a2916da98806e30423d27671cfee21b6 to your computer and use it in GitHub Desktop.
Borderless opencv window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_window_borderless(self): | |
""" | |
Requires: pywin32 | |
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32 | |
import win32gui as wg | |
import win32api as wa | |
import win32con as wc | |
Based on: https://github.com/howardjohn/pyty/blob/master/src/window_api.py | |
""" | |
def restore(hwnd): | |
""" | |
Restores (unmaximizes) the window. | |
Args: | |
hwnd (int): The window handler. | |
""" | |
wg.ShowWindow(hwnd, wc.SW_RESTORE) | |
def maximize(hwnd): | |
""" | |
Maximizes the window. | |
Args: | |
hwnd (int): The window handler. | |
""" | |
wg.ShowWindow(hwnd, wc.SW_MAXIMIZE) | |
def hwnd_for_title(title): | |
def cb(hwnd, param): | |
title = ''.join(char for char in wg.GetWindowText(hwnd) if ord(char) <= 126) | |
d[title] = hwnd | |
d = {} | |
wg.EnumWindows(cb, title) | |
if title in d: | |
return d[title] | |
else: | |
return None | |
hwnd = hwnd_for_title(self.window_name) | |
style = wg.GetWindowLong(hwnd, wc.GWL_STYLE) | |
style &= ~wc.WS_OVERLAPPEDWINDOW | |
style |= wc.WS_POPUP | |
wg.SetWindowLong(hwnd, wc.GWL_STYLE, style) | |
rgb = wg.CreateSolidBrush(wa.RGB(0, 0, 0)) | |
GCLP_HBRBACKGROUND = -10 | |
wa.SetClassLong(hwnd, GCLP_HBRBACKGROUND, rgb) | |
maximize(hwnd) | |
restore(hwnd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment