Within a Filemaker Pro application I need to know if the application “iTunes” is currently open. I am using applescript to find this out. I have searched here and found two basic ways:
[
if (my test_process(“iTunes”)) then
display dialog “true”
else
display dialog “false”
end if
on test_process(which_app)
–this tests if the process “iTunes” is running
if (do shell script “ps -ax | grep /Applications”) contains which_app then
set processRunning to true
return processRunning
else
set processRunning to false
return processRunning
end if
end test_processt]
This is applescript is fast, but returns “true” even if the program “iTunes” is not open. Presumably it is because other programs open a process using “iTunes” in it’s name.
the other option is:
[tell application “System Events”
if exists process “iTunes” then
set is_running to true
else
set is_running to false
end if
end tell
]
This is slower, but accurately returns “false” if the user has not opened 'iTunes".
anyone have any thoughts on an accurate and fast option to this problem
thank you
Model: macbook pro
AppleScript: 2.6.1
Browser: Safari 537.77.4
Operating System: Mac OS X (10.8)