如何在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!
我想把记事本窗口强行放在前面 即使选择了其他应用程序。