os.system("open /Applications/Mail.app")
I’m able to open mac applications using the above statement(though not able to open applications which include spaces in their name. eg.Photo Booth).
But I cannot find a method to close apps.How do i do that? Googled a lot but all the solutions mentioned were for windows.
With respect to opening applications with spaces, you’ll probably find you can do something like:
or:
The reason why there’s probably not an equivalent
closecommand is because it unbalanced.Opening two applications with the same parameters is easily done, you just create two separate processes. However, when you then want to close one, which gets hit? They both have the same name.
You can look into using
killonce you establish the process ID of the process you’re trying to get rid of, or you can useosascriptto tell applications to exit: