I’m trying to quit an app that is sometimes called Capture One 10 and sometimes called Capture One 11 etc etc
the code I’m using is
set targetApp to "Capture One 10"
tell application "System Events"
set processExists to exists process targetApp
end tell
if processExists is true then
tell application targetApp
quit
end tell
end if
But I need quit any version of Capture One that is running???
Cheers
Hi.
Does this work?
tell application "System Events" to set CaptureOneNames to name of application processes whose name begins with "Capture One"
repeat with thisName in CaptureOneNames
tell application thisName to quit
end repeat
Perfectly thanks
When I tried
tell application "System Events"
set theName to get name of every application process whose name contains "Capture One"
end tell
tell application theName to quit
it would error? I guess its because the result is a list not and not an actual name? The repeat even if there is only one app open fixed it???
That’s right. An alternative would be to get the name of the first application process whose name contains “Capture One”. That would return just a name. But then you’d get an error if there was no such process, because you can’t get a property of something which doesn’t exist. It’s confusing because if you ask for the name of every such process when there is none, you get an empty list, not an error! I’m not sure if that’s meant to happen, but it’s useful here. The script I posted works if there’s no such process, only one, or several.