Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- from __future__ import print_function
- from ctypes import windll, WINFUNCTYPE, POINTER, c_bool, c_int, create_unicode_buffer
- EnumWindows = windll.user32.EnumWindows
- EnumChildWindows = windll.user32.EnumChildWindows
- SetWindowPos = windll.user32.SetWindowPos
- GetWindowLong = windll.user32.GetWindowLongA
- SetWindowLong = windll.user32.SetWindowLongA
- SetLayeredWindowAttributes = windll.user32.SetLayeredWindowAttributes
- EnumWindowsProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))
- GetWindowText = windll.user32.GetWindowTextW
- GetWindowTextLength = windll.user32.GetWindowTextLengthW
- IsWindowVisible = windll.user32.IsWindowVisible
- windows = []
- def foreach_window(hwnd, lParam):
- if IsWindowVisible(hwnd):
- length = GetWindowTextLength(hwnd)
- buff = create_unicode_buffer(length + 1)
- GetWindowText(hwnd, buff, length + 1)
- windows.append([hwnd, buff.value])
- return True
- subwindows = []
- def foreach_subwindow(hwnd, lParam):
- if IsWindowVisible(hwnd):
- length = GetWindowTextLength(hwnd)
- buff = create_unicode_buffer(length + 1)
- GetWindowText(hwnd, buff, length + 1)
- subwindows.append([hwnd, buff.value])
- return True
- del windows[:]
- EnumWindows(EnumWindowsProc(foreach_window), 0)
- for hwnd, title in windows:
- if 'Index of /dev/' in title:
- print(hwnd, title)
- if False:
- # try to resize the entire window in fullscreen,
- # works but bounces back on mouseover
- SWP_NOZORDER = 0x0004
- SWP_NOACTIVATE = 0x0010
- SWP_NOSENDCHANGING = 0x0400
- SWP_NOREPOSITION = 0x0200
- SetWindowPos(hwnd, None, 256, 128, 512, 384,
- SWP_NOZORDER + SWP_NOACTIVATE + SWP_NOSENDCHANGING)
- break
- else:
- # "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app=https://ocv.me/dev/
- #
- GWL_STYLE = -16;
- WS_BORDER = 0x800000; # has border
- WS_DLGFRAME = 0x400000; # has double border but no title
- WS_CAPTION = WS_BORDER + WS_DLGFRAME; # has title bar
- style = GetWindowLong(hwnd, GWL_STYLE)
- style = style & ~WS_CAPTION
- SetWindowLong(hwnd, GWL_STYLE, style)
- # resize the window to trigger a redraw by chrome
- SWP_NOACTIVATE = 0x0010
- SWP_NOZORDER = 0x0004
- SWP_NOMOVE = 0x0002
- SWP_NOSIZE = 0x0001
- SetWindowPos(hwnd, None, 256, 512, 1024, 768, \
- SWP_NOACTIVATE + \
- SWP_NOZORDER)
- break
- del subwindows[:]
- EnumChildWindows(hwnd, EnumWindowsProc(foreach_subwindow), 0)
- for n, (hwnd2, title2) in enumerate(subwindows, 1):
- #SetWindowPos(hwnd2, None, n * 256, n * 128, n * 512, n * 384, 0x4+0x400+0x200+0x10)
- if False:
- # move inner window up, works but mouse is off
- SWP_NOZORDER = 0x0004
- SWP_NOSENDCHANGING = 0x0400
- SWP_NOREPOSITION = 0x0200
- SWP_NOACTIVATE = 0x0010
- SWP_NOMOVE = 0x0002
- SWP_NOSIZE = 0x0001
- if n == 2:
- SetWindowPos(hwnd2, None, 0, -85, 0, 0, \
- SWP_NOZORDER + \
- SWP_NOACTIVATE + \
- SWP_NOSIZE)
- return
- elif False:
- # set alpha of parent window, implementation error causes border to become fully black instead
- LWA_KEY = 1;
- LWA_ALPHA = 2;
- # bool SetLayeredWindowAttributes(
- # IntPtr hWnd, uint crKey, byte bAlpha, uint dwFlags);
- GWL_STYLE = -16;
- GWL_EXSTYLE = -20;
- WS_EX_LAYERED = 0x80000;
- WS_CHILD = 0x40000000;
- WS_BORDER = 0x800000; # has border
- WS_DLGFRAME = 0x400000; # has double border but no title
- WS_CAPTION = WS_BORDER + WS_DLGFRAME; # has title bar
- # SetLayeredWindowAttributes(
- # hwnd, 0, (byte)opac, LWA_ALPHA)
- if n == 2:
- wcfg = GetWindowLong(hwnd2, GWL_EXSTYLE)
- print(wcfg)
- #continue
- wcfg = wcfg ^ WS_EX_LAYERED
- print(wcfg)
- #continue
- SetWindowLong(hwnd2, GWL_EXSTYLE, wcfg)
- SetLayeredWindowAttributes(hwnd2, 0, LWA_ALPHA)
- return
Advertisement
Add Comment
Please, Sign In to add comment