2016-11-22 5 views
0

J'avais l'habitude d'utiliser le script Apple suivant pour trouver l'image papier peint réelle sur mon moniteur (mode double) et le montrer dans finder. Sous El Capitan, le script fonctionne bien. Après avoir installé Mac OS Sierra le script affiche le message d'erreurAprès l'installation de macOS-sierra Apple script montrant fond d'écran réel dans Finder ne fonctionne plus

"error "„Finder“ hat einen Fehler erhalten: Die Routine kann Objekte dieser Klasse nicht bearbeiten." number -10010"

Anglais Traduction:

"error "„Finder“ received an error: The routine cannot work with objects of this class.“ number - 10010". The object which is highlighted in the script is "reveal rotationImage"

Je ne suis pas un spécialiste du script de pomme. Malheureusement, je n'ai trouvé aucune aide sur le web. Quel pourrait être le problème?

tell application "System Events" 
    set posix_path to (pictures folder of desktop 1) 
    set picPath to (POSIX file posix_path) as string 
end tell 
set thePictures to (do shell script "sqlite3 ~/Library/Application\\ Support/Dock/desktoppicture.db \"SELECT data.value FROM preferences INNER JOIN data on preferences.key=16 and preferences.picture_id=5 and preferences.data_id=data.ROWID\"") 
set fullPath to picPath as string 
set rotationImage to fullPath & thePictures 
tell application "Finder" 
    reveal rotationImage 
    activate 
end tell 
tell application "Finder" 
    get selection 
    repeat with moose in result 
     if original item of moose exists then 
      reveal original item of moose 
     end if 
    end repeat 
end tell 

Répondre

0

Le script fonctionne sur ma machine, même sur la Sierra, une raison de l'échec pourrait être que reveal attend une référence de fichier plutôt que d'une chaîne littérale.

Ceci est une version légèrement optimisée de votre script:

tell application "System Events" 
    set posix_path to (pictures folder of desktop 1) 
    set picPath to (POSIX file posix_path) as string 
end tell 
set thePictures to (do shell script "sqlite3 ~/Library/Application\\ Support/Dock/desktoppicture.db \"SELECT data.value FROM preferences INNER JOIN data on preferences.key=16 and preferences.picture_id=5 and preferences.data_id=data.ROWID\"") 
set fullPath to picPath as string 
set rotationImage to fullPath & thePictures 
tell application "Finder" 
    try 
     set aliasItem to item rotationImage 
     if class of aliasItem is alias file then 
      reveal original item of aliasItem 
     end if 
    end try 
end tell 
+0

Salut Vadian, le script fonctionne parfaitement. Merci beaucoup pour votre aide. Comme je ne suis pas un bon programmeur de scripts, je n'aurais probablement jamais trouvé cette solution. Cordialement, afrikapit – afrikapit