def check_needs_reset(self): if self.hwnd: if not win32gui.IsWindow(self.hwnd): logger.warning(f"HWND became invalid - resetting") return True style = win32api.GetWindowLong(self.hwnd, GWL_STYLE) if style != self.style: logger.warning(f"GWL_STYLE changed - resetting") return True ex_style = win32api.GetWindowLong(self.hwnd, GWL_EXSTYLE) if ex_style != self.ex_style: logger.warning(f"GWL_EXSTYLE changed - resetting") return True win_rect = win32gui.GetWindowRect(self.hwnd) if win_rect != self.win_rect: logger.warning(f"WindowRect changed - resetting") return True client_rect = win32gui.GetClientRect(self.hwnd) if client_rect != self.client_rect: logger.warning(f"ClientRect changed - resetting") return True if self.foreground: monitor = _get_monitor_containing(self.win_rect.center, self.monitors) if not monitor or self.monitor != monitor: logger.warning( f"Monitor containing center changed - resetting") return True return False
def prepare_style_build(self): if self._handle is not None: self._style = win32api.GetWindowLong(self._handle, win32con.GWL_STYLE) self._extStyle = win32api.GetWindowLong(self._handle, win32con.GWL_EXSTYLE) if self._style and self._extStyle is not 0: return True else: return False
def classify_window(hwnd): # Invisible windows are ignored until they become visible if not win32gui.IsWindowVisible(hwnd): return None, IgnoreTemporary, "Invisible" # Cloaked windows are not handled if pylewm.window.is_window_handle_cloaked(hwnd): return None, IgnoreTemporary, "Cloaked" style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) exStyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) window = pylewm.window.Window(hwnd) # Windows with no title are temporary and should be ignored if window.window_title == '': return None, IgnoreTemporary, "Empty Title" # Windows with no title are temporary and should be ignored if window.window_title in ALWAYS_IGNORE_TITLES: return None, IgnoreTemporary, "Always Ignored by Name" # Check if any filters ignore this if pylewm.filters.is_ignored(window): return None, IgnorePermanent, "Ignored by Filter" # Don't bother with windows that don't overlap the desktop at all if not window.rect.overlaps(pylewm.monitors.DesktopArea): return None, IgnoreTemporary, "Off Screen" # Windows with 0 size are not managed if window.rect.height == 0 or window.rect.width == 0: return window, IgnorePermanent, "Zero Size" # Special always ignored classes window_class = window.window_class.lower() if window_class in ALWAYS_IGNORE_CLASSES: return window, IgnorePermanent, "Ignored Class" # NOACTIVATE windows that aren't APPWINDOW are ignored by # the taskbar, so we probably should ignore them as well if (exStyle & win32con.WS_EX_NOACTIVATE ) and not (exStyle & win32con.WS_EX_APPWINDOW): return window, IgnorePermanent, "Not AppWindow" # Windows that aren't resizable are ignored, # we can usually assume these aren't available for tiling. if not (style & win32con.WS_SIZEBOX): return window, Floating, "No Resize" # Some classes that Windows uses should always be realistically floating if window_class in ALWAYS_FLOATING_CLASSES: return window, Floating, "Floating Class" return window, Tiled, None
def set_top(hwnd): win32gui.SetWindowPos(hwnd,win32con.HWND_TOPMOST,x,y,w,h,win32con.SWP_NOACTIVATE) twitch_bot_utils.printer("SetWindowPos to HWND_TOPMOST and SWP_NOACTIVATE") style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) twitch_bot_utils.printer("Got style %X before" % style) style = style | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOPMOST twitch_bot_utils.printer("Setting style %X" % style) win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style) twitch_bot_utils.printer("Set style %X" % style) style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) twitch_bot_utils.printer("Got style %X after" % style)
def set_top(hwnd): win32gui.SetWindowPos(hwnd,win32con.HWND_TOPMOST,0,0,width,height,win32con.SWP_NOACTIVATE) logging.log(logging.DEBUG,"SetWindowPos to HWND_TOPMOST and SWP_NOACTIVATE") style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) logging.log(logging.DEBUG,"Got style %X before" % style) style = style | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOPMOST logging.log(logging.DEBUG,"Setting style %X" % style) win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style) logging.log(logging.DEBUG,"Set style %X" % style) style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) logging.log(logging.DEBUG,"Got style %X after" % style)
def __init__(self, hwnd): self.handle = hwnd self.last_window_pos = win32gui.GetWindowRect(self.handle) self.last_received_pos = self.last_window_pos self.rect = Rect(self.last_window_pos) self.floating_rect = self.rect.copy() self.last_set_rect = self.rect.copy() self.window_class = win32gui.GetClassName(hwnd) self.window_title = win32gui.GetWindowText(hwnd) self.space = None self.closed = False self.focused = False self.hidden = False self.becoming_visible = False self.floating = False self.can_tile = True self.take_new_rect = False self.force_closed = False self.always_top = False self.force_always_top = False self.force_borders = None self.minimized = False self.is_dropdown = False parent_handle = win32api.GetWindowLong(self.handle, win32con.GWL_HWNDPARENT) self.is_child_window = win32gui.IsWindow(parent_handle) self.dragging = False self.drag_ticks_with_movement = 0 self.drag_ticks_since_start = 0 self.drag_ticks_since_last_movement = 0 self.drop_space = None self.drop_slot = None self.drop_ticks_inside_slot = 0
def enum_windows_proc(hwnd, l_param): if (l_param is None) or ((l_param is not None) and (win32process.GetWindowThreadProcessId(hwnd)[1] == l_param)): text = win32gui.GetWindowText(hwnd) if text: w_style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) if w_style & win32con.WS_VISIBLE: hwnds.append(hwnd)
def enumWindowsProc(self, hwnd, lParam): if win32process.GetWindowThreadProcessId(hwnd)[1] == lParam: text = win32gui.GetWindowText(hwnd) if text and (win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) & win32con.WS_VISIBLE): self.windowTitle = text return
def fixup_window_style(self, *args): """ a fixup function we want to call from other places """ hwnd = get_window_handle(self) if not hwnd: return try: #warning: accessing "_metadata" on the client window class is fugly.. metadata = getattr(self, "_metadata", {}) if metadata.get("modal", False): #window is not / no longer meant to be decorated #(this is what GTK does for modal windows - keep it consistent) return cur_style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) #re-add taskbar menu: style = cur_style if cur_style & win32con.WS_CAPTION: style |= win32con.WS_SYSMENU style |= win32con.WS_MAXIMIZEBOX style |= win32con.WS_MINIMIZEBOX if style != cur_style: log( "fixup_window_style() using %s (%#x) instead of %s (%#x) on window %#x with metadata=%s", style_str(style), style, style_str(cur_style), cur_style, hwnd, metadata) win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style) else: log( "fixup_window_style() unchanged style %s (%#x) on window %#x", style_str(style), style, hwnd) except: log.warn("failed to fixup window style", exc_info=True)
def setTransparency(hwnd, amount): """ This is how the method SetTransparent()is implemented on all MS Windows platforms. """ try: import ctypes _winlib = ctypes.windll.user32 style = _winlib.GetWindowLongA(hwnd, 0xffffffecL) style |= 0x00080000 _winlib.SetWindowLongA(hwnd, 0xffffffecL, style) _winlib.SetLayeredWindowAttributes(hwnd, 0, amount, 2) except ImportError: import win32api import win32con import winxpgui _winlib = win32api.LoadLibrary("user32") pSetLayeredWindowAttributes = win32api.GetProcAddress( _winlib, "SetLayeredWindowAttributes") if pSetLayeredWindowAttributes is None: return exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if (exstyle & 0x80000) == 0: win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle | 0x80000) winxpgui.SetLayeredWindowAttributes(hwnd, 0, amount, 2)
def ignoresFocus(self): if skos.WIN: hwnd = skwin.hwnd_from_wid(self.winId()) style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) return bool(style & win32con.WS_EX_NOACTIVATE) else: return False
def MakeWindowTransparent(self, amount): """ Makes the :class:`SuperToolTip` window transparent. :param `amount`: the alpha channel value. :note: This method is available only on Windows and requires Mark Hammond's pywin32 package. """ if not _libimported: # No way, only Windows XP with Mark Hammond's win32all return # this API call is not in all SDKs, only the newer ones, so # we will runtime bind this if wx.Platform != "__WXMSW__": return hwnd = self.GetHandle() if not hasattr(self, "_winlib"): self._winlib = win32api.LoadLibrary("user32") pSetLayeredWindowAttributes = win32api.GetProcAddress(self._winlib, "SetLayeredWindowAttributes") if pSetLayeredWindowAttributes == None: return exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if 0 == (exstyle & 0x80000): win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle | 0x80000) winxpgui.SetLayeredWindowAttributes(hwnd, 0, amount, 2)
def handler(hwnd, results): if (win32api.GetWindowLong(hwnd, win32con.GWL_ID) == 0x3EC and win32gui.GetClassName(hwnd) == 'Static'): results.append(hwnd) return False enum_children(hwnd, results) return len(results) == 0
def pointer_grab(window, *args): hwnd = get_window_handle(window) grablog("pointer_grab%s window=%s, hwnd=%s", args, window, hwnd) if not hwnd: window._client.pointer_grabbed = False return wx1,wy1,wx2,wy2 = win32gui.GetWindowRect(hwnd) grablog("GetWindowRect(%i)=%s", hwnd, (wx1,wy1,wx2,wy2)) try: DwmGetWindowAttribute = ctypes.windll.dwmapi.DwmGetWindowAttribute # Vista & 7 stuff rect = ctypes.wintypes.RECT() DWMWA_EXTENDED_FRAME_BOUNDS = 9 DwmGetWindowAttribute(HWND(hwnd), DWORD(DWMWA_EXTENDED_FRAME_BOUNDS), byref(rect), sizeof(rect)) #wx1,wy1,wx2,wy2 = rect.left, rect.top, rect.right, rect.bottom grablog("DwmGetWindowAttribute: DWMWA_EXTENDED_FRAME_BOUNDS(%i)=%s", hwnd, (rect.left, rect.top, rect.right, rect.bottom)) except WindowsError as e: #@UndefinedVariable grablog("no DwmGetWindowAttribute: %s", e) bx = win32api.GetSystemMetrics(win32con.SM_CXSIZEFRAME) by = win32api.GetSystemMetrics(win32con.SM_CYSIZEFRAME) top = by style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) if style & win32con.WS_CAPTION: top += win32api.GetSystemMetrics(win32con.SM_CYCAPTION) grablog(" window style=%s, SIZEFRAME=%s, top=%i", style_str(style), (bx, by), top) clip = (wx1+bx, wy1+top, wx2-bx, wy2-by) grablog("ClipCursor%s", clip) win32api.ClipCursor(clip) window._client.pointer_grabbed = True
def MakeTransparent(self, alpha): import os, sys # input parameter Excel you from 0 to 100 to be consistent with other # transparency models. # The method below takes a value from 0 to 255. Need to make the mapping. winAlpha = int(alpha * 2.55) if sys.platform == 'win32': hwnd = self.GetHandle() try: import ctypes # DLL library interface constants' definitions _winlib = ctypes.windll.user32 # create object to access DLL file user32.dll style = _winlib.GetWindowLongA(hwnd, 0xffffffecL) style |= 0x00080000 _winlib.SetWindowLongA(hwnd, 0xffffffecL, style) _winlib.SetLayeredWindowAttributes(hwnd, 0, winAlpha, 2) except ImportError: import win32api, win32con, winxpgui _winlib = win32api.LoadLibrary("user32") pSetLayeredWindowAttributes = win32api.GetProcAddress( _winlib, "SetLayeredWindowAttributes") if pSetLayeredWindowAttributes == None: return exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if 0 == (exstyle & 0x80000): win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle | 0x80000) winxpgui.SetLayeredWindowAttributes(hwnd, 0, amount, 2) else: print '#### OS Platform must be MS Windows' self.Destroy()
def MakeTransparent(self, amount): """ This is how the method SetTransparent() is implemented on all MS Windows platforms. """ import os if os.name == 'nt': # could substitute: sys.platform == 'win32' hwnd = self.GetHandle() try: import ctypes # DLL library interface constants' definitions _winlib = ctypes.windll.user32 # create object to access DLL file user32.dll style = _winlib.GetWindowLongA(hwnd, '0xffff') style |= 0x00080000 _winlib.SetWindowLongA(hwnd, '0xffff', style) _winlib.SetLayeredWindowAttributes(hwnd, 0, amount, 2) except ImportError: import win32api import win32con import winxpgui _winlib = win32api.LoadLibrary("user32") pSetLayeredWindowAttributes = win32api.GetProcAddress( _winlib, "SetLayeredWindowAttributes") if pSetLayeredWindowAttributes == None: return exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if 0 == (exstyle & 0x80000): win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle | 0x80000) winxpgui.SetLayeredWindowAttributes(hwnd, 0, amount, 2) else: print('OS Platform must be MS Windows') self.Destroy()
def OnCommand(self, hwnd, msg, wparam, lparam): FolderSelector_Parent.OnCommand(self, hwnd, msg, wparam, lparam) id = win32api.LOWORD(wparam) id_name = self._GetIDName(id) code = win32api.HIWORD(wparam) if code == win32con.BN_CLICKED: if id in (win32con.IDOK, win32con.IDCANCEL) and self.in_label_edit: cancel = id == win32con.IDCANCEL win32gui.SendMessage(self.list, commctrl.TVM_ENDEDITLABELNOW, cancel, 0) return # Button clicks if id == win32con.IDOK: if not self._CheckSelectionsValid(True): return self.selected_ids, self.checkbox_state = self.GetSelectedIDs() win32gui.EndDialog(hwnd, id) elif id == win32con.IDCANCEL: win32gui.EndDialog(hwnd, id) elif id_name == "IDC_BUT_CLEARALL": for info, spec in self._YieldCheckedChildren(): self.UnselectItem(info) elif id_name == "IDC_BUT_NEW": # Force a new entry in the tree at our location, and begin # editing. # Add the new item to the tree. h = win32gui.SendMessage(self.list, commctrl.TVM_GETNEXTITEM, commctrl.TVGN_CARET, commctrl.TVI_ROOT) parent_item = self._GetTVItem(h) if parent_item[6] == 0: # eeek - parent has no existig children - say we have one # so we can be expanded. update_item, extra = PackTVITEM(h, None, None, None, None, None, 1, None) win32gui.SendMessage(self.list, commctrl.TVM_SETITEM, 0, update_item) item_id = self._MakeItemParam(None) temp_spec = FolderSpec(None, "New folder") hnew = self._InsertFolder(h, temp_spec, None, commctrl.TVI_FIRST) win32gui.SendMessage(self.list, commctrl.TVM_ENSUREVISIBLE, 0, hnew) win32gui.SendMessage(self.list, commctrl.TVM_SELECTITEM, commctrl.TVGN_CARET, hnew) # Allow label editing s = win32api.GetWindowLong(self.list, win32con.GWL_STYLE) s |= commctrl.TVS_EDITLABELS win32api.SetWindowLong(self.list, win32con.GWL_STYLE, s) win32gui.SetFocus(self.list) self.in_label_edit = True win32gui.SendMessage(self.list, commctrl.TVM_EDITLABEL, 0, hnew) self._UpdateStatus()
def _sendNotifyMessage(hwnd, nofifyMessage): '''Send a notify message to a control.''' win32gui.SendMessage(win32gui.GetParent(hwnd), win32con.WM_COMMAND, _buildWinLong(nofifyMessage, win32api.GetWindowLong(hwnd, win32con.GWL_ID)), hwnd)
def set_top(hwnd, x1, y1): x = 640 y = 512 w = int(round(x1 / 2)) h = int(round(y1 / 2)) win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 1280, 1024, win32con.SWP_NOACTIVATE) print("SetWindowPos to HWND_TOPMOST and SWP_NOACTIVATE") style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) print("Got style %X before" % style) style = style | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOPMOST print("Setting style %X" % style) win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style) print("Set style %X" % style) style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) print("Got style %X after" % style)
def OnInitialUpdate(self): hwnd = self._obj_.GetSafeHwnd() style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE); win32api.SetWindowLong(hwnd, win32con.GWL_STYLE, (style & ~commctrl.LVS_TYPEMASK) | commctrl.LVS_REPORT); itemDetails = (commctrl.LVCFMT_LEFT, 100, "Name", 0) self.InsertColumn(0, itemDetails) itemDetails = (commctrl.LVCFMT_LEFT, 500, "Data", 0) self.InsertColumn(1, itemDetails)
def enumWindowsProc(hwnd, lParam): """ append window titles which match a pid """ if (lParam is None) or ((lParam is not None) and (win32process.GetWindowThreadProcessId(hwnd)[1] == lParam)): text = win32gui.GetWindowText(hwnd) if text: wStyle = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) if wStyle & win32con.WS_VISIBLE: t.append("%s" % (text)) return
def SetCompositeMode(self, on=True): exstyle = win32api.GetWindowLong(self.GetHandle(), win32con.GWL_EXSTYLE) if on: exstyle |= win32con.WS_EX_COMPOSITED else: exstyle &= ~win32con.WS_EX_COMPOSITED win32api.SetWindowLong(self.GetHandle(), win32con.GWL_EXSTYLE, exstyle)
def remove_taskbar_button(self): """隐藏窗口从任务栏和ALT+TAB对话框。""" win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE) win32api.SetWindowLong( self.hwnd, win32con.GWL_EXSTYLE, win32api.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_NOACTIVATE | win32con.WS_EX_TOOLWINDOW) win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW)
def remove_taskbar_button(self): """Hide window from taskbar and ALT+TAB dialog.""" win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE) win32api.SetWindowLong( self.hwnd, win32con.GWL_EXSTYLE, win32api.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_NOACTIVATE | win32con.WS_EX_TOOLWINDOW) win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW)
def enumWindowsProc(hwnd, lParam): global currentWindowTitle if (lParam is None) or ( (lParam is not None) and (win32process.GetWindowThreadProcessId(hwnd)[1] == lParam)): text = win32gui.GetWindowText(hwnd) if text: wStyle = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE) if wStyle & win32con.WS_VISIBLE: currentWindowTitle = text
def setIgnoresFocus(self, value): if skos.WIN: dprint("value = %s" % value) hwnd = skwin.hwnd_from_wid(self.winId()) style = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) if value != bool(style & win32con.WS_EX_NOACTIVATE): style = (style | win32con.WS_EX_NOACTIVATE if value else style & ~win32con.WS_EX_NOACTIVATE) #win32gui.ShowWindow(hwnd, win32con.SW_HIDE) win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style)
def OnInitDialog(self): self.SetWindowText("Enter new value") self.GetDlgItem(win32con.IDCANCEL).ShowWindow(win32con.SW_SHOW) self.edit = self.GetDlgItem(win32ui.IDC_EDIT1) # Modify the edit windows style style = win32api.GetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE) style = style & (~win32con.ES_WANTRETURN) win32api.SetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE, style) self.edit.SetWindowText(str(self.item)) self.edit.SetSel(-1) return dialog.Dialog.OnInitDialog(self)
def activate(): bkgndWndClass = win32gui.WNDCLASS() bkgndWndClass.hbrBackground = win32gui.GetStockObject(win32con.BLACK_BRUSH) bkgndWndClass.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW) bkgndWndClass.lpszClassName = 'VimFullscreenBkgnd' class_atom = win32gui.RegisterClass(bkgndWndClass) top_wnd = win32gui.FindWindow('Vim', None) mon = win32api.MonitorFromRect(win32gui.GetWindowRect(top_wnd), win32con.MONITOR_DEFAULTTONEAREST) (x, y, dx, dy) = win32api.GetMonitorInfo(mon)['Monitor'] old_window_placement = win32gui.GetWindowPlacement(top_wnd) old_style = win32api.GetWindowLong(top_wnd, win32con.GWL_STYLE) old_exstyle = win32api.GetWindowLong(top_wnd, win32con.GWL_EXSTYLE) win32api.SetWindowLong( top_wnd, win32con.GWL_STYLE, old_style & ~(win32con.WS_CAPTION | win32con.WS_BORDER | win32con.WS_THICKFRAME)) win32api.SetWindowLong(top_wnd, win32con.GWL_EXSTYLE, old_exstyle & ~win32con.WS_EX_WINDOWEDGE) win32gui.SetWindowPos(top_wnd, win32con.HWND_TOP, x, y, dx - x, dy - y, win32con.SWP_SHOWWINDOW | win32con.SWP_FRAMECHANGED) # Black background bkgnd_wnd = win32gui.CreateWindow(class_atom, '', win32con.WS_CHILD, 0, 0, dx - x, dy - y, top_wnd, None, win32api.GetModuleHandle(None), None) win32gui.SetWindowPos( bkgnd_wnd, win32con.HWND_BOTTOM, 0, 0, 0, 0, win32con.SWP_NOACTIVATE | win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_SHOWWINDOW) restore_data = { 'window_placement': old_window_placement, 'style': old_style, 'exstyle': old_exstyle, 'class_atom': class_atom, 'bkgnd_wnd': bkgnd_wnd } vim.vars.update({'fullscreen_restoredata': restore_data}) vim.vars.update({'fullscreen_active': 1})
def adjust_position_for_window(self, position): if self.force_borders is not None: if self.force_borders == 0: return else: position[0] += self.force_borders position[1] += self.force_borders position[2] -= self.force_borders*2 position[3] -= self.force_borders*2 return style = win32api.GetWindowLong(self.handle, win32con.GWL_STYLE) if not (style & win32con.WS_SYSMENU): position[0] += 2 position[2] -= 4 position[3] -= 3 return exStyle = win32api.GetWindowLong(self.handle, win32con.GWL_EXSTYLE) adjusted = ctypes.wintypes.RECT() adjusted.left = position[0] adjusted.top = position[1] adjusted.right = position[0] + position[2] adjusted.bottom = position[1] + position[3] ctypes.windll.user32.AdjustWindowRectEx( ctypes.pointer(adjusted), ctypes.c_uint(style), False, ctypes.c_uint(exStyle), ) position[0] = adjusted.left + 3 position[1] += 2 position[2] = adjusted.right - adjusted.left - 6 position[3] = adjusted.bottom - position[1] - 3
def enum_windows_process(window_handle, process_pid): (other_thread_id, other_process_id) = win32process.GetWindowThreadProcessId(window_handle) if other_process_id != process_pid: return text = win32gui.GetWindowText(window_handle) if not text: return window_style = win32api.GetWindowLong(window_handle, win32con.GWL_STYLE) if window_style & win32con.WS_VISIBLE: titles.append(text)