2016-11-22 49 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