Re: Language-independent way to find Applications
Re: Language-independent way to find Applications
- Subject: Re: Language-independent way to find Applications
- From: KOENIG Yvan <email@hidden>
- Date: Mon, 17 Mar 2008 18:00:00 +0100
Le 17 mars 2008 à 17:01, KOENIG Yvan a écrit :
‘
get path of process whose displayed name is "Photoshop.app"
Of course, it's wrong.
a - a process hasn't a path but a file
b - proces whose condition doesn't work (at least with 10.4)
Here is the exact code which I uses.
set {path11, path12} to my commun("PagesAnglais")
set {path21, path22} to my commun("Pages")
log path11 & return & path12 & return & path21 & return & path22
(*
alias Macintosh HD:Applications:iWork '08:PagesAnglais.app:, [OK]
, false, [OK]
, alias Macintosh HD:Applications:iWork '08:Pages.app:, [OK]
, alias Macintosh HD:Applications:iWork '08:PagesAnglais.app: [WRONG]
*)
on commun(the_App)
set vers to version of application the_App
set pat to my getAppProcess(the_App, "displayed name")
if pat > 0 then
tell application "System Events" to set pat to file of process pat
else
set pat to false
end if
copy pat to pat1
set pat to my getAppProcess(the_App, "name")
if pat > 0 then
tell application "System Events" to set pat to file of process pat
else
set pat to false
end if
copy pat to pat2
return {pat1, pat2}
end commun
on getAppProcess(theApp, what)
if what is not in {"displayed name", "name"} then error
tell application "System Events"
if what is "name" then
set listProcesses to (name of processes)
else
set listProcesses to (displayed name of processes)
end if
repeat with i from 1 to count of listProcesses
set running to 0
if what is "name" then
set flag to item i of listProcesses is theApp
else
set flag to item i of listProcesses is theApp & ".app"
end if
if flag then
set running to i
exit repeat
end if
end repeat
end tell
return running
end getAppProcess
As I wrote in a recent post, I work mainly with displayed name
because I'm often working with two copies of the same application
with two different names.
Pages.app and PagesAnglais.app
If I run PagesAnglais before Pages, the process named "Pages" linked
to PagesAnglais.app is before the one linked to Pages.app so, using
the simple name gives odd results.
Yvan KOENIG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden