简体   繁体   中英

"Double Clicking" or Enter on selected file in windows explorer

I'm trying to simulate "double click" or enter on a selected file in windows explorer (win10pro) after I've run this code:

import subprocess
os.chdir("C:/Users/***/***/DeforumStableDiffusionLocal")
subprocess.Popen(r'explorer /select, "C:\Users\***\***\DeforumStableDiffusionLocal\run_still.bat')

I've tried importing the keyboard module but I'm a little confused as to how it would interact with the opened explorer window.
Normally i would run within python, but I'm trying to streamline with another program where I'm getting weird SSL errors from within the program, but when run in windows explorer it works fine. Thanks in advance!

In native Windows you would use ShellExecute . In Python you should use os.startfile(myfilepath) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM