2016-11-22 51 views
0

我用下面的腳本蘋果找到了我的顯示器(雙模式)的實際壁紙圖片,並顯示在取景器。在El Capitan之下,劇本工作正常。我安裝了Mac OS塞拉利昂之後,腳本顯示錯誤消息安裝的MacOS-Sierra的蘋果腳本顯示取景器實際壁紙後不能正常工作不再

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

翻譯:

"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"

我不是一個蘋果腳本專家。不幸的是我無法找到網絡上的任何幫助。可能是什麼問題呢?

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 

回答

0

腳本作品在我的機器甚至在塞拉利昂上,失敗的原因可能是reveal期望一個文件引用,而不是一個字符串。

這是你的腳本稍微優化版本:

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

vadian嗨,腳本運行完美。非常感謝您的幫助。因爲我不是一個好劇本的程序員,我可能會沒有找到這個解決方案。親切的問候,afrikapit – afrikapit