Applescript : installer une police

Publié : 04.06.2012 - 16h16 par ndubau

Bonjour,
Suis très novice en matière d'AS. J'ai commis la chose suivante qui permet d'installer une police requise par une application via le livre de polices.

Code : Tout sélectionner

-- Chemin d'accès du présent script
set theScriptPath to path to me

-- chemin du dossier actuel
tell application "Finder"
   set my_folder_path to container of (path to me) as text
   
   -- Chemin d'accès à la police
   set theFontPath to my_folder_path & "IDAutomationHC39M.ttf"
end tell

set theFont to theFontPath

-- installation police
tell application "Finder"
   open theFontPath
end tell

tell application "Font Book"
   
   if installation target is not font domain "User" then
      set installation target to font domain "User"
   end if
   
   activate
   set theFontWindow to the first window
end tell


tell application "System Events"
   tell process "Font Book"
      tell window 1
         tell group 1
            click button "Installer la police"
         end tell
      end tell
   end tell
end tell


Cela fonctionne au détaisl suivant près : si la police existe déjà pour l'user ou le système une alerte vient ponctuer l'installation car il y a détection de doublon. Comment faire pour ne procéder à l'installation que si la police ne préexiste pas ?
Merci aux spécialiste de ce codage !
Noël