繁体   English   中英

如何在Windows 10中以编程方式调整过程窗口的大小?

[英]How to programmatically resize process windows in Windows 10?

我正在使用python通过vlc一次打开4个视频,我希望它们在屏幕的每四分之一处自动调整大小(因为将窗口拖动到角落时会发生这种情况)。

我正在使用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提供的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM