'tell application "System Events"', '-e'
'count (every process whose name is "' + app + '")', '-e'
How to use python to detect if an application is running and if a message box is displayed under MAC OS