6
import os
os.system("notepad macros.txt")

or

from subprocess import Popen
Popen(["notepad", "macros.txt"])

both start notepad in the background. How to start it in the foreground?

1 Answer 1

2

You can try to use the start command, maybe the /MAX option will force notepad to be in foreground, otherwise if you can wait untill notepad shutdown, use the /WAIT option/

Popen(["start", "/MAX", "notepad", "macros.txt"], shell=True)
Sign up to request clarification or add additional context in comments.

3 Comments

It seems this code does not work in Windows: "WindowsError: [Error 2]"
@DSblizzard : I add the shell=True parameter (otherwise you'll have to specify the complete pathes), on my WindowsXP it works even without the /MAX option.
is possible to populate a cmd? something like process = subprocess.Popen(["start", "C:\Windows\System32\cmd.exe", "cd C:/folder;dir"], shell=True) I want to be able to open 3 cmd windows and start certain programs from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.