如何以编程方式在 Windows 10 中调整进程 windows 的大小?

How to programmatically resize process windows in Windows 10?

我正在使用 python 通过 vlc 一次打开 4 个视频,我希望它们在屏幕的每个四分之一处自动调整大小(当您将 window 拖动到角落)。

我正在使用 subprocess 库的 Popen 方法,如下所示:

for i in range(0,4):
    p = subprocess.Popen(['vlc location','file name'])
p.wait()

到目前为止,视频已打开,但我不知道如何像这样将它们固定在角落:

如果您要像我一样使用 Popen 子进程方法,则必须删除 p.wait(),因为它将等待视频在 运行 之前结束队列中的进程而不是线程化它们)。

在 martineau 的帮助和他提供的答案下,我使用了以下内容(在为 python 3.5 安装 pywin32 之后):

import pywintypes
import win32gui

displays = [[-10,0,980,530],
        [954,0,980,530],
        [-10,515,980,530],
        [954,515,980,530]] #these are the x1,y1,x2,y2 to corner all 4 videos on my res (1920x1080)

def enumHandler(hwnd, lParam):
    if win32gui.IsWindowVisible(hwnd):
        print(win32gui.GetWindowText(hwnd)) #this will print all the processes title
        if name in win32gui.GetWindowText(hwnd): #it checks if the process I'm looking for is running
            win32gui.MoveWindow(hwnd,i0,i1,i2,i3,True) #resizes and moves the process

win32gui.EnumWindows(enumHandler, None) #this is how to run enumHandler

x1、y1、x2、y2 可能与您的进程不同,但这些对于 vlc 媒体播放器来说工作得很好。我希望我已经足够清楚了,但如果你没有完成它,你一定要检查 martineau 提供的答案。