Python Forum
Process execution using Popen - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Process execution using Popen (/thread-22901.html)



Process execution using Popen - Shaswat - Dec-02-2019

Hi Everyone,

Good Day!

I learn few things about how to create new process using Subprocess module in Python. Indeed, I am more curious to know if I can open new process and select more functionality of the newly created process.

e.g.

Rather opening just notepad++.exe, I'd like to open a new tab with "Language" select as C.
Also instead of open snipping tool, I'd be glad if I open SnippingTool.exe along with "new snip" option selected.

According to the manual, Subprocess module lets us spawn new processes, connect to their input/error/output pipes, and acquire their return codes.

Specific in Popen, args argument "should be a sequence of program arguments".

Is there any way that I can write my code the way I want in python? Is there any other module that helps me to execute my thoughts?

Thanks in advance!


RE: Process execution using Popen - scidam - Dec-03-2019

(Dec-02-2019, 01:15 PM)Shaswat Wrote: Rather opening just notepad++.exe, I'd like to open a new tab with "Language" select as C.
Ability to do this depends on how notepad++ is developed. If it allows execution via command line something like "notepad++.exe --default-language=C" (I use --default-language option as an example, I don't know anything about notepad++), then you can easily do what you want. If don't, the only way is to run notepad++ and then emulate some actions (move mouse, click on desired tab etc) to get desired result. This question doesn't related to Python and Subproces module in general, everything depends on what you want to get, and how programs are implemented (does they allow external control by design).


RE: Process execution using Popen - Shaswat - Dec-03-2019

Understood.
Many thanks for the explanation.
P.S. A little web search provide me PyAutoGUI library.