I am creating a windows automation script. I need to bring Excel application to foreground. I am able to open excel application and get list of subprocess running. But i am not sure how to Excel application to foreground. Please help
import subprocess
from win32com.client import Dispatch
xl = Dispatch("Excel.Application")
xl.Visible = True
cmd = 'WMIC PROCESS get Caption,Commandline,Processid'
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
for line in proc.stdout:
print(line)
I am getting list of applications open, but i need to bring Excel to foreground. Please help me how to do it.
b'EXCEL.EXE "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
b'SearchFilterHost.exe 740 \r\r\n' b'python.exe C:\Users\arvin\AppData\Local\Programs\Python\Python37-32\python.exe \r\r\n' b'conhost.exe \??\C:\WINDOWS\system32\conhost.exe 0x4 15724 \r\r\n' b'cmd.exe C:\WINDOWS\system32\cmd.exe /c "WMIC PROCESS get Caption,Commandline,Processid" 18084 \r\r\n'