繁体   English   中英

无法使用 AppleScript 在 Mac 上设置桌面背景

[英]Can't set Desktop Background on Mac with AppleScript

我正在尝试设置我的 Mac 的桌面壁纸(运行最新版本的 Catalina)。 但是在尝试运行我的苹果脚本时,我不断收到此错误消息。

错误“系统事件出现错误:无法将当前桌面的文件 \"Library:Desktop Pictures:Ink Cloud.jpg:\" 设置为当前桌面的文件 \"Library:Desktop Pictures:Ink Cloud.jpg:\"。 " 当前桌面的文件“库:桌面图片:Ink Cloud.jpg:”中的编号 -10006

这是我的代码

tell application "System Events"
    tell current desktop
        set picture rotation to 0
        set picture to file "Library:Desktop Pictures:Ink Cloud.jpg:"
    end tell
end tell 

除了实际照片之外,我已经能够更改桌面的所有其他属性。 我也尝试使用 / 作为文件路径。 我尝试了不同的文件路径。 但还是不走运。 任何帮助或建议将不胜感激。

运行代码

tell application "System Events"
    set currentPicturePath to picture of current desktop
end tell

表明该路径应该是(斜线分隔的)POSIX 路径

tell application "System Events"
    tell current desktop
        set picture rotation to 0
        set picture to "/Library/Desktop Pictures/Ink Cloud.jpg"
    end tell
end tell 

您的(冒号分隔的)HFS 路径包含两个错误:

  • HFS 路径(与 POSIX 路径不同)总是以磁盘名称开头。
  • 只有对文件夹和包的引用有一个尾随冒号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM