2014-12-01 67 views
0

我目前使用applescript在我的大學設置桌面的各種參數。到目前爲止,我的腳本已成功更改桌面背景和底座大小。使用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

我沒有讓你的腳本工作可靠。我玩了超時,但沒有讓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中的時間,呼吸和使用該腳本每次工作......

但有一件事是AFAIK不可能在Finder中的腳本:設置格柵間距: -/

邁克爾/漢堡問候語

+0

謝謝@ShooTerKo。我想知道爲什麼直接編輯首選項文件是不可靠的,它在碼頭大小的100%的時間內工作。這絕對讓我更接近我的目標。感謝您的幫助伴侶。乾杯! – 2014-12-03 22:34:36