【问题标题】:How do I deploy my applescript to multiple devices?如何将我的 applescript 部署到多个设备?
【发布时间】:2020-05-04 15:29:19
【问题描述】:

这听起来像是一个愚蠢的问题,因为我不知道如何正确表达它。但基本上我想创建一个包含照片的包,然后创建一个脚本来将该照片设置为该设备的壁纸。这是专门针对 Catalina 的,所以我无法修改 Desktop Photos 文件夹。我遇到的问题是,如果我下载照片,文件路径将附加给用户。但我不能使用像 $currentuser 这样的东西作为文件路径的一部分。只是希望对如何解决这个问题有任何想法。我对applescript也很陌生,所以可能是我缺少的东西。谢谢你。

    tell current desktop
        set picture to file "/Users/lemur/Pictures/bluemoon.jpg" as POSIX file
    end tell
end tell

【问题讨论】:

  • 我还没有真正创建包。我试图找出最好的方法。虽然谢谢你的建议,但我会试试看。

标签: macos applescript macos-catalina


【解决方案1】:

这里有五个两行示例可能会有所帮助。运行每个并检查结果:

set fd to path to desktop
return fd
set fd to path to applications folder
return fd
set fd to (path to applications folder from user domain)
return fd
set fd to path to pictures folder
return fd
set fd to path to desktop pictures folder
return fd

【讨论】:

    【解决方案2】:

    正如您与System Events 交谈的那样,语法非常简单

    tell application "System Events"
        tell current desktop
            set picture to file "bluemoon.jpg" of pictures folder
        end tell
    end tell
    

    pictures folder始终是当前用户的图片文件夹

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多