赞
踩
import win32gui # 查找窗口句柄 def getHwnd(clzName,title): hwnd = win32gui.FindWindow(clzName, title) return hwnd # 获取窗口标题 def getTitle(hwnd): return win32gui.GetWindowText(hwnd) # 查找控件句柄 def getChildHwnd(hwnd,parentHwnd,clzName,winName): return win32gui.FindWindowEx(hwnd, parentHwnd, clzName, winName) # 窗口位置大小 def get_window_pos_size(hwnd): window_rect = win32gui.GetWindowRect(hwnd) x = window_rect[0] y = window_rect[1] width = window_rect[2] - x height = window_rect[3] - y return x, y, width, height
最小化窗口:win32gui.MinimizeWindow(handle)
最大化窗口:win32gui.MaximizeWindow(handle)
还原窗口:win32gui.RestoreWindow(handle)
激活窗口:win32gui.SetActiveWindow(handle)
置顶窗口:win32gui.SetForegroundWindow(handle)
取消置顶:win32gui.SetForegroundWindow(0)
设置窗口大小:win32gui.SetWindowPos(handle, None, x, y, width, height, flags)
获取窗口大小:win32gui.GetWindowRect(handle)
移动窗口:win32gui.MoveWindow(handle, x, y, width, height, repaint)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。