2

I want to open VM player application through python code and I have to import/open VM file but whenever I tried opening the application through subprocess.Popen(self.vmware_path) python code line, it invokes the application at random x,y position.

I have researched some of the possibilities in the subprocess.Popen (STARTUPINOF) but I'm not able to understand the concept of STARTUPINFO class. os.system by this, I could open the application but not able to do it with the predefined position.

    # print pyautogui.position()
    # print pyautogui.size()  # current screen resolution width and height
    # pyautogui.PAUSE = 1
    # pyautogui.FAILSAFE = True

    subprocess.Popen(self.vmware_path)

    # si = subprocess.STARTUPINFO()
    # si.dwFlags = subprocess.STARTF_USESHOWWINDOW
    # si.wShowWindow = 3

Here what I need is,

  1. I have to open VM player application by pyautogui or any other python module along with below support.
    • it should accept predefined window size or
    • it should maximize the application to the actual monitor size.
Santhosh
  • 49
  • 2
  • 10

1 Answers1

2

From pyautogui module, not possible to start the application directly.But you can use the os module to launch the application.

Sample:

import os
os.system('start "" "' + path+ '"')

note: path of the application with name

it will launch the application and maximize the screen , then you can use pyautogui to get the screen data(size, position etc).

NPC
  • 80
  • 6