1

I'm using python to open 4 videos at once with vlc and I want them to be resized automatically in each quarter of the screen (as it happens when you drag the window in the corner).

I'm using the Popen method of the subprocess library as follows:

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

So far the videos open but I can't figure it out how to pin them in the corners like this:

screenshot of desired results

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Cristian G
  • 460
  • 1
  • 4
  • 22
  • [This answer](http://stackoverflow.com/a/14654287/355230) to an unrelated question shows how to use `win32gui.MoveWindow()` to position windows on the Windows desktop (as well as how to iterate through all those that are visible). Something like that is what you need to do. – martineau Feb 12 '17 at 16:21
  • 1
    Thank you! It solved my problem. – Cristian G Feb 12 '17 at 19:27
  • You're quite welcome. `:-)` When you're allowed to (after a certain amount of time), you can post an answer to your own question which would help others with a similar problem. – martineau Feb 12 '17 at 19:30

1 Answers1

3

If you are going to use the Popen subprocess method as I did you will have to remove p.wait() because it will wait for the video to end before running anymore code (it's putting the processes in a queue instead of threading them).

With the help from martineau and the answer he provided I used the following (after installing the pywin32 for python 3.5):

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

The x1,y1,x2,y2 might be different for your processes but these work just fine for vlc media player. I hope I was clear enough but if you don't get it done you should definitely check the answer provided by martineau.

Cristian G
  • 460
  • 1
  • 4
  • 22