I've written some Applescript to create a list of paths of all applications running in the dock:
set appsRunning to [] tell application "System Events" repeat with p in every application process if background only of p is false then set appsRunning to appsRunning & POSIX path of (path to application p) end if end repeat end tell
But when it runs I get the error - "Can't make application into type constant" and it highlights
path to application p
.I don't understand why this happens because when I run
set q to POSIX path of (path to application "Finder") -- or any other application
I get no error whatsoever and I see
"/System/Library/CoreServices/Finder.app/"
returned in the Results field.How can I get this to work?
P.S. For my purposes it is essential that I get the path - the application name simply won't do. (This is because when I get the name of the application process, some of my applications which are SSBs made using Fluid return
"FluidApp"
as their name instead of"Gmail"
or"Tumblr"
or whatever site it is that I've made into an application. I need to distinguish between these and that only happens when I get the path.)Any help would be appreciated! Thanks.
Update: I used an amended version of the first suggestion in @vadian's answer to solve my problem:
set appsRunning to {}
tell application "System Events"
repeat with aProcess in (get application file of every application process whose background only is false)
set appsRunning to appsRunning & POSIX path of aProcess
end repeat
end tell