i've written applescript create list of paths of applications running in dock:
set appsrunning [] tell application "system events" repeat p in every application process if background of p false set appsrunning appsrunning & posix path of (path application p) end if end repeat end tellbut when runs error - "can't make application type constant" , highlights
path application p.i don't understand why happens because when run
set q posix path of (path application "finder") -- or other applicationi no error whatsoever , see
"/system/library/coreservices/finder.app/"returned in results field.how can work?
p.s. purposes essential path - application name won't do. (this because when name of application process, of applications ssbs made using fluid return
"fluidapp"name instead of"gmail"or"tumblr"or whatever site i've made application. need distinguish between these , happens when path.)any appreciated! thanks.
update: used amended version of first suggestion in @vadian's answer solve problem:
set appsrunning {} tell application "system events" repeat aprocess in (get application file of every application process background false) set appsrunning appsrunning & posix path of aprocess end repeat end tell
the element application process of system events has property application file, can posix path directly from.
set appsrunning {} tell application "system events" repeat aprocess in (get every application process background false) set end of appsrunning posix path of application file of aprocess end repeat end tell or easier
tell application "system events" set appsrunning posix path of application file of every application process background false end tell additional here solution excludes finder because runs time , path fixed
tell application "system events" set appsrunning posix path of application file of every application process background false , name not "finder" end tell set end of appsrunning "/system/library/coreservices/finder.app" another solution using original approach
set appsrunning {} tell application "system events" set applicationnames name of every application process background false end tell repeat aname in applicationnames set end of appsrunning posix path of (path application aname) end repeat and last not least applescriptobjc version (mavericks , higher, in mavericks in script library)
set appsrunning (current application's nsworkspace's sharedworkspace()'s launchedapplications()'s valueforkey:"nsapplicationpath") list though method launchedapplications of nsworkspace deprecated, works in yosemite
to use applescriptobjc in script library save code
use framework "foundation" on launchedapplications() return (current application's nsworkspace's sharedworkspace()'s launchedapplications()'s valueforkey:"nsapplicationpath") list end launchedapplications as script bundle (in mavericks have check "applescript/objective-c library" in side bar of script) in ~/library/script libraries. create folder if doesn't exist.
now can call script library normal script file (the script library named "nsworkspace.scptd")
use script "nsworkspace" set appsrunning launchedapplications() of script "nsworkspace"
Comments
Post a Comment