首页 > 解决方案 > 如何将我的 applescript 部署到多个设备?

问题描述

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

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

标签: macosapplescriptmacos-catalina

解决方案


无论如何,正如您所说的那样System Events,语法非常简单

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

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


推荐阅读