def EnumWindowsHandler2(hwnd, extra): if win32gui.GetWindowTextLength(hwnd) != 0 and \ win32gui.IsWindowEnabled(hwnd) and \ win32gui.IsWindowVisible(hwnd) and \ win32gui.GetWindowLong(hwnd, win32con.WS_EX_TOOLWINDOW) == 0 and \ win32gui.GetParent(hwnd) == 0: extra.add((hwnd, win32gui.GetWindowText(hwnd)))
def _setRoot(self, init_line): root = tk.Tk() root.title(init_line) # configure the overlay widget, aka the master widget of the line we have created root.overrideredirect( True ) # this prevents the override from behaving like a regular window root.geometry(f'+{self.position["X"]}+{self.position["Y"]}' ) # this sets overlay's initial position root.minsize( 500, 20) # set minimum widget size to max of what it will ever be root.configure( bg=self.colors['background']) # set the BG colour of the widget root.wm_attributes( '-topmost', True) # make sure the overlay widget stays on top of other windows root.wm_attributes( '-alpha', self.opacity) # set opacity to make the widget semi-transparent root.update() # set the window to allow clicking events to go through window = win32gui.FindWindow(None, init_line) # find our window to edit it lExStyle = win32gui.GetWindowLong(window, win32con.GWL_EXSTYLE) lExStyle |= win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED win32gui.SetWindowLong(window, win32con.GWL_EXSTYLE, lExStyle) return root
def setWindowAnimation(self, hWnd): """ 打开窗口动画效果 """ style = win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE) win32gui.SetWindowLong( hWnd, win32con.GWL_STYLE, style | win32con.WS_MAXIMIZEBOX | win32con.WS_CAPTION | win32con.CS_DBLCLKS | win32con.WS_THICKFRAME)
def EnumWindowsHandler(hwnd, extra): style = win32gui.GetWindowLong(hwnd, -16) if style & 0x10000000 == 0x10000000 and style & 0x00C00000 == 0x00C00000: if win32gui.GetWindowTextLength(hwnd) != 0: if win32gui.IsWindowVisible(hwnd) and win32gui.GetParent( hwnd) == 0: hicon = win32gui.GetClassLong(hwnd, -14) if hicon: extra.add((hwnd, win32gui.GetWindowText(hwnd)))
def addWindowAnimation(self, hWnd): """ 打开窗口动画效果 Parameters ---------- hWnd : int or `sip.voidptr` 窗口句柄 """ style = win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE) win32gui.SetWindowLong( hWnd, win32con.GWL_STYLE, style | win32con.WS_MAXIMIZEBOX | win32con.WS_CAPTION | win32con.CS_DBLCLKS | win32con.WS_THICKFRAME, )
def obsLikeHandler(hwnd, extra): styles = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE) exStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if win32gui.IsWindowVisible(hwnd) and styles & win32con.WS_CHILD == 0 and \ exStyle & win32con.WS_EX_TOOLWINDOW == 0 and win32gui.GetWindowText(hwnd) != '': extra.add((hwnd, win32gui.GetWindowText(hwnd)))
def __get_style_long(self): """Get window style WinAPI flags.""" # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlonga return win32gui.GetWindowLong(self.__hwnd, win32con.GWL_STYLE)