microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

Minimize WinAppDriver.exe programmatically #1700

Open Urvika-gola opened 2 years ago

Urvika-gola commented 2 years ago

is there any argument that can be passed to WinAppDriver.exe while launching such that it opens it in a minimized way?

Note, that I tried this on command prompt and it works fine start "" /min "C:\Program Files\Windows Application Driver\WinAppDriver.exe" but, I am using psexec, and the same command, when used with psexec, doesn't work. PsExec.exe -nobanner -accepteula -i 1 \\localhost -u username -p password "start \"\" /min \"C:\Program Files\Windows Application Driver\WinAppDriver.exe\""

PsExec could not start start "" /min "C:\Program Files\Windows Application Driver\WinAppDriver.exe" on localhost:
The filename, directory name, or volume label syntax is incorrect. 

So, it would have been altogether easier if there is any argument that WinAppDriver can take while launching it from the command prompt. It will be really helpful, considering WinAppDriver is used for automation (hence programmatically), and since it's related to UI, it would be helpful to open it in a minimized state so that it doesn't hinder UI elements on the screen.

How do you all approach this problem?

anunay1 commented 2 years ago

you can use the key combination windowskey+d, it will minimize all the windows, but what is the issue it's causing?

Urvika-gola commented 2 years ago

That can be done, but I am looking to launch it in minimized mode. Win+d will minimize everything on the screen, I want to avoid this.

anunay1 commented 2 years ago

Which language binding are you using?

Urvika-gola commented 2 years ago

Python.

anunay1 commented 2 years ago

Is its C# then using system.process you can launch WAD in minimize mode

anunay1 commented 2 years ago

try this

import subprocess

def startProgram():
    SW_MINIMIZE = 6
    info = subprocess.STARTUPINFO()
    info.dwFlags = subprocess.STARTF_USESHOWWINDOW
    info.wShowWindow = SW_MINIMIZE
    subprocess.Popen(r'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe', startupinfo=info)

startProgram()