如何在MS Windows上强制使用Python的“subprocess”模块来应用(如记事本)?
环境:Windows XP,Python 2.5.4
我尝试了以下。
## Notepad is invoked in front >>> import subprocess >>> command = r'notepad C:\tmp\foo.txt' >>> subprocess.Popen(command) # opened in front ## Notepad is invoked but not in front >>> import subprocess, time >>> command = r'notepad C:\tmp\foo.txt' >>> time.sleep(5) # click other application while sleeping >>> subprocess.Popen(command) # opened but not in front!
即使select了其他应用程序,我也要强制记事本窗口在前面。