Hello. I want to start an external program in Processing and Processing should detect whether this program has also been started. How can I realize this?
I’m not familiar with these exceptions.
Thanks…Frank
Hello @Frank,
Welcome to the forum.
Processing provides a simple launch utility:
launch() / Reference / Processing.org
Example:
launch("notepad.exe"); // Works on Windows 10
This is what launch() is doing “under the hood”:
processing4/core/src/processing/core/PApplet.java at main · processing/processing4 · GitHub
launch() is using the Java Runtime exec() method.
Since Processing runs on Java, you can also use standard Java libraries. If you prefer more control, look into ProcessBuilder and integrate it directly into your sketch.
Minimal example that works in static mode on W10:
try
{
Process p = new ProcessBuilder("notepad.exe").start(); // Windows
println(p.isAlive());
}
catch (Exception e)
{
}
Have fun!
:)
Thank you very much. I’ll try it out tomorrow morning
Frank
1 Like
Thank you, it works
Frank
1 Like