How to port an application from Python to MS Windows?

How to bring an application (e.g. Notepad) forward forcefully with the Python subprocess module in MS Windows?

Environment: Windows XP, Python 2.5.4

I tried the following.

## 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!

I want the notepad window to be forced even if another application is selected.

+3
source share

Source: https://habr.com/ru/post/1775946/


All Articles