Using subprocess
I want to open Windows File Explorer. Then wait for 1 second and close it:
import subprocess, time
subprocess.Popen(r'explorer /select,"D:\tmp\temp"')
time.sleep(1)
How to close File Explorer?
Using subprocess
I want to open Windows File Explorer. Then wait for 1 second and close it:
import subprocess, time
subprocess.Popen(r'explorer /select,"D:\tmp\temp"')
time.sleep(1)
How to close File Explorer?
I hope it works
import subprocess
import time
from pygetwindow import getWindowsWithTitle
from pywinauto import Application
# Open
subprocess.Popen(r'explorer /select,"D:\tmp\temp"')
time.sleep(1)
#locate window
explorer_windows = getWindowsWithTitle("This PC")
time.sleep(1)
# Close the window
window = explorer_windows[0]
app = Application().connect(handle=window._hWnd)
app.top_window().close()