Re: Detecting Applescript and SKYPE
Re: Detecting Applescript and SKYPE
- Subject: Re: Detecting Applescript and SKYPE
- From: Sander Tekelenburg <email@hidden>
- Date: Fri, 10 Oct 2008 20:17:10 +0200
At 09:29 -0700 UTC, on 2008-10-10, Michelle Steiner wrote:
> On Oct 10, 2008, at 9:12 AM, Peter Baxter wrote:
>
>> To detect if a particular application is installed, a script like
>> the following will do:
>>
>>
>> tell application "Finder"
>> try
>> if exists alias "Macintosh HD:Applications:SKYPE.app:" then
>> display dialog "Boo"
>> else
>> display dialog "Boo Hoo"
>> end if
>> end try
>> end tell
>
> To make it more portable, and to take into account that it might be in
> the user's applications folder, try this:
>
> tell application "Finder"
> if exists alias "skype.app" in (path to applications folder) then
> display dialog "Boo"
> else if exists alias "skype.app" in (path to applications folder from
> user domain) then
> display dialog "Boo"
> else
> display dialog "Boo hoo"
> end if
> end tell
Better, but ignores that the app might be installed elsewhere still. Most
apps are not required to be in /Applications or ~/Applications. The app might
be in a subfolder, or even somewhere else completely.
August 31 Joseph Weaks posted a more elegant/flexible approach, which for
this particular case would be:
(* start script *)
--returns true if the app is installed, wherever that is; false if it isn't
set appInstalled to false
try
tell application "Finder"
set appInstalled to exists (application file id "com.skype.skype")
end tell
end try
return appInstalled
(* end script *)
[gotchas]
- the script writer needs to know the application file id of the app in
question, of course
- I'm assuming LaunchServices/Finder get updated when an app is uninstalled;
haven't verified...
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
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