This is the best way I can find to test if an application is running under appscript:
try:
app('System Events').processes['AppName']()
except:
print 'Application AppName is not running'
I think it’s kinda neat. I’d like to know of a better method, but I looked pretty hard!
Burn Down The Mission (Live) • Elton John • Live In Australia ★
I believe in Leopard, there is dtrace as well.. I have been keeping some notes on leopard here
23 hours, 41 minutes after the fact.
System Events’ ‘exists’ command can be used to text for the existence of a specified element or elements:
isrunning = app('System Events').processes['AppName'].exists()Note that with the above approach (which uses the by-name reference form), process names are case-sensitive for some reason. If you want case-insensitivity, using the by-test reference form seems to work:
isrunning = app('System Events').processes[its.name == 'AppName'].exists()Alternatively, you can use the aem module to check for a running process based on the application’s path:
from aem import Applicationisrunning = Application.isrunning('/path/to/some.app')
aem also includes a findapp module that you can use to locate an application by name, creator type or bundle id. The appscript documentation has more info on this.
1 day, 4 hours after the fact.
Thanks. That probably is nicer than mine.
I’ve only just started playing with appscript properly. It is übercool, but I clearly don’t grok everything it can do just yet!
1 day, 21 hours after the fact.