I’m trying to figure out a script to search in the app Activity Monitor to see wether or not a process is running.
It works fine with the app names in the list of running processes, but when I try for example to see if “https://itunes.apple.com” is running it reports back as False, even though its running among the rest in the list…
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set safRunning to is_running("https://itunes.apple.com")
return safRunning
if false then
tell application "Safari"
end tell
end if
Browser: Safari 602.3.12
Operating System: Mac OS X (10.10)
The problem is that System Events process listing is very limited. If the process you want to check is an application that is launched by you or on your behalve System Events is safe to check for running processes. Other processes cannot be listed and not be checked by system events.
The second thing is the false process name activity monitor will list. There is no process with the name http://itunes.apple.com. However there is an XPC service spawned by Safari to manage web content in your browser. The actual process name is probably com.apple.WebKit.WebContent. Having multiple windows or tabs open is hard to tell which process belongs to which content so therefore activity monitor will list the URL.