0
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.

1 Answer 1

1

With respect to opening applications with spaces, you'll probably find you can do something like:

os.system("open \"/Applications/Photo Booth.app\"")

or:

os.system('open "/Applications/Photo Booth.app"')

The reason why there's probably not an equivalent close command 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 kill once you establish the process ID of the process you're trying to get rid of, or you can use osascript to tell applications to exit:

osascript -e 'tell application "PaxsDodgyApp" to quit'
Sign up to request clarification or add additional context in comments.

Comments

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.