我正在尝试制作一个applescript,让我将桌面图片更改为硬盘驱动器文件夹中的随机图片
tell application "Finder"
set desktopPictures to folder "Path:To:Desktop:Pictures:"
set fileList to name of every file of desktopPictures
set theNum to random number from 1 to (count fileList) with seed ((time of (current date)) * 4)
set fileName to item theNum of fileList
set desktop picture to file fileName in desktopPictures
end tell
到目前为止它工作得很好,我唯一的问题是当我连接另一台显示器时,他的桌面图片不会改变。我尝试使用以下代码解决此问题,我发现进行网络搜索
tell application "Finder"
set desktopPictures to folder "Path:To:Desktop:Pictures:"
set fileList to name of every file of desktopPictures
set theDesktops to a reference to every desktop
repeat with aDesktop in theDesktops
set theNum to random number from 1 to (count fileList) with seed ((time of (current date)) * 4)
set fileName to item theNum of fileList
set picture of aDesktop to file fileName in desktopPictures
end repeat
end tell
但是这段代码无法编译,因为我收到一个语法错误:
Expected class name but found property.
在desktop
第 4 行突出显示