What’s the best way to see if a given application is running? This script will be running on a MacOS 10.2.8 system.
… I was about to post an answer, not sure if it’e the best mind you, but I have no idea if it will work. I’ve only been using AppleScript for a short time and have no experience pre 10.3.9 with AS
I think even then there was an Activity Monitor (in Applications/Utilities). With your app running, see what its process is called (not always the same as the app). Then try this:
tell application "System Events" to exists process "Safari" -- replacing "Safari" with your App's process name
set appRunning to result
tell application "System Events" to exists process "HP Communications"
set appRunning to result
if result is false
tell application "HP Communications"
activate
end tell
if result is true
tell application "HP Communications"
activate
end tell
If I add a END TELL statement to the first TELL APPLICATION I get an error. If I don’t put one , I also get an error message. What is wrong with this script ?
Robert
Model: iMac G5 1.6 MHZ - 2GB
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi Robert,
It’s been a while since I ran scripts without System Events beta. You’re probably not using the beta version. Try using the Finder instead:
tell application "Finder"
set se_exists to exists process "Script Editor"
end tell
if not se_exists then
tell application "Script Editor" to activate
end if
Edited: I wish you would respond with your thoughts, because I’m curious also.
gl,
Hi Robert,
launch, activate, quit and reopen can be used directly without a tell block
activate application "HP Communications"
Hi Stephan,
What is the synthax error of this script
tell application "System Events" to exists process "HP Communications"
set appRunning to result
if result is true
activate application "HP Communications
end tell
Regards.
Model: iMac G5 1.6 MHZ - 2GB
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi Robert,
What is it that I have to do to make you see?
gl,
Either
tell application "System Events" to exists process "HP Communications"
set appRunning to result
if result is true then
activate application "HP Communications
end if
or the short version:
tell application "System Events" to exists process "HP Communications"
if result then activate application "HP Communications"