python 操作窗口
// windows 窗口属性获取 https://files.cnblogs.com/files/han-guang-xue/windowsx.rar
python .\xxx.py 300 300 PX_WINDOW_CLASS
import win32gui
import win32api
import win32con
import sys
windth = sys.argv[1]
height = sys.argv[2]
findClassName = sys.argv[3]
# findClassName = "PX_WINDOW_CLASS"
windth = 500
height = 300
clist = []
def show_window_attr(hWnd):
'''
显示窗口的属性
:return:
'''
if not hWnd:
return
clsname = win32gui.GetClassName(hWnd)
if clsname == findClassName:
clist.append(hWnd)
# print(hWnd, title, clsname);
def show_windows(hWndList):
for h in hWndList:
show_window_attr(h)
def demo_top_windows():
'''
演示如何列出所有的顶级窗口
:return:
'''
hWndList = []
win32gui.EnumWindows(lambda hWnd, param: param.append(hWnd), hWndList)
show_windows(hWndList)
return hWndList
demo_top_windows()
x = 0
y = 0
len = len(clist)
count = 0
for item in clist:
if(count == len/2):
y = height
x = 0
win32gui.SetWindowPos(item,win32con.HWND_TOP,x, y, windth, height, win32con.SWP_SHOWWINDOW)
# win32gui.SetWindowPos(item,win32con.HWND_BOTTOM,x, y, windth, height, win32con.SWP_SHOWWINDOW)
x += windth
count+=1
本文来自博客园踩坑狭,作者:韩若明瞳,转载请注明原文链接:https://www.cnblogs.com/han-guang-xue/p/15612492.html