使用Applescript更改桌面图标大小

时间:2014-12-01 21:21:31

标签: macos applescript osx-mountain-lion

我目前正在使用applescript在我的大学设置桌面的各种参数。到目前为止,我的脚本成功更改了桌面背景和扩展坞大小。

手头的问题是当我运行脚本时,大多数时候,桌面上的图标永远不会改变。

这是我编写的用于更改桌面图标大小和网格间距的脚本:

tell application "System Events"
    set finderPrefsFile to property list file "~/Library/Preferences/com.apple.Finder.plist"
    tell finderPrefsFile
        tell property list item "DesktopViewSettings"
            tell property list item "IconViewSettings"
                set value of property list item "gridSpacing" to "100"
                set value of property list item "iconSize" to "32"
                set value of property list item "arrangeBy" to "none"
            end tell
        end tell
    end tell
end tell
#Restart Finder for changes to take effect.
do shell script "killall Finder"

我应该如何改变脚本以使其始终有效(我希望最终与我的一些同学分享这个脚本)。

P.S。 Here is the full script

1 个答案:

答案 0 :(得分:1)

我没有让你的脚本工作可靠。我玩了超时,但没有使用新设置让Finder刷新。 但我发现使用vanilla AppleScript直接设置一些视图选项:

tell application "Finder"
    activate
    set iconViewOptions to desktop's window's icon view options
    tell iconViewOptions
        set arrangement to not arranged
        set icon size to 32
        set shows item info to false
        set shows icon preview to false
    end tell
    quit
end tell
delay 1
tell application "Finder" to activate

AppleScript quit - 处理程序比do shell script "killall Finder"更可靠,也许killall太难了......

delay 1能够让Finder有时间再次起床并使用它,每次都可以使用脚本......

但有一点是AFAIK在Finder脚本编写中不可能:设置网格空间: - /

问候,迈克尔/汉堡

相关问题