macos - 如何将我的 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
解决方案
无论如何,正如您所说的那样System Events
,语法非常简单
tell application "System Events"
tell current desktop
set picture to file "bluemoon.jpg" of pictures folder
end tell
end tell
pictures folder
始终是当前用户的图片文件夹
推荐阅读
- javascript - Discord.js - 如何编辑 message.embed() 语句?
- python - 使用 C 绑定导入代码的 Pickle 模块
- node.js - 如何用玩笑模拟 AxiosInstance
- python - 如何将字典中的所有元素放入数据库
- pyspark - 在 Databricks 中使用 Spark API 连接到 ADLS
- arrays - 谷歌表格数组求和文本
- ruby-on-rails - 为什么我在尝试播种 csv 数据时看到此错误消息
- docker - docker-jenkins 容器无法访问互联网
- python - 将存储过程结果存储在数据框中时,MySql 命令不同步
- reactjs - 如何使用 React Native (Expo) 将文件/图像上传到 Azure Blob?