【问题标题】:Using Applescript to Change desktop icon size使用 Applescript 更改桌面图标大小
【发布时间】:2015-01-29 23:59:09
【问题描述】:

我目前正在使用 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"

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

附: Here is the full script

【问题讨论】:

    标签: macos applescript osx-mountain-lion


    【解决方案1】:

    我没有让你的脚本工作可靠。我玩过超时,但没有让 Finder 使用新设置刷新。 但我发现直接使用香草 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-handler 比 do shell script "killall Finder" 更可靠,也许 killall 太难了...

    delay 1 具有魔力,让 Finder 有时间在再次起床之前呼吸,并且每次使用它,脚本都能正常工作...

    但有一件事是在 Finder 脚本中无法使用 AFAIK:设置网格空间:-/

    你好,迈克尔/汉堡

    【讨论】:

    • 谢谢@ShooTerKo。我想知道为什么直接编辑首选项文件是不可靠的,它在 100% 的时间内都可以使用停靠大小。这绝对让我离我的目标更近了。谢谢你的帮助伙伴。干杯!
    猜你喜欢
    • 2018-05-19
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多