I have read before on here that you cannot adjust the gridSpacing via applescript. However I figured that it must exist on the com.apple.finder.plist and under DesktopViewSettings > IconViewSettings > gridSpacing.
Now when I adjust the slider on the finder > View > Show View Options you can adjust the slider and see that value change in the plist anything from 1 to 100 and then of course the icons move about on the desktop accordingly.
Now I made an applescript, as it works, in that you see the grid spacing value change, however nothing happens on the desktop! I tried using the clean up command, nothing.I tried relaunching the finder and also logging out and back in. Still nothing. it must be possibly to do?
Anyone have any ideas how to do it?
tell application "System Events"
set plistFile to property list file ((path to preferences as text) & "com.apple.finder.plist")
tell plistFile
tell property list item "DesktopViewSettings"
tell property list item "IconViewSettings"
--set value of property list item "gridSpacing"
set value of property list item "gridSpacing" to "90"
end tell
end tell
end tell
end tell
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)
activate application "Finder"
tell application "System Events" to tell application process "Finder"
if not (exists (first window whose subrole is "AXSystemFloatingWindow")) then
keystroke "j" using {command down}
repeat until exists (first window whose subrole is "AXSystemFloatingWindow")
delay 0.1
end repeat
end if
tell (first window whose subrole is "AXSystemFloatingWindow") to tell first group
get value of slider 1 # To get the value in use in a window using default spacing
set value of slider 1 to 10.0
end tell
end tell
I have changed your last effort a little, inserting an extra cmd-J at the end, to make the window go away, and an cmd-1 at the beggining so that you are in “Icon mode” before you start changing.
As for your first effort, which I logged on for commenting really "The fox saw the rowan berries, and said they hang high, and are soure, before he moved on.
There are some long number strings inside that propertylist file, if memory serves, that I believe have something to say for the parsing of the parameters. You’ll have a hard time figuring out how to change those strings, by observing the diferences you accomplish by the slider-bars, and then the strings might be hashed, so that there are in reality a serialized object in there. You’ll have a hard time figuring that out!
I think your last solution is more than good enough for me at least. As for the desktop window, I think you’ll have to bring the desktop in focus, and then address it from there. But then again: Do the Desktop window share the properties with the rest of the Finder windows?, and if it isn’t so, then it isn’t that hard to do once. Unfortuntately you can’t use UI scripting and keystroke the “status window” for the desktop.
activate application "Finder"
tell application "System Events" to tell application process "Finder"
if not (exists (first window whose subrole is "AXSystemFloatingWindow")) then
keystroke "1" using {command down}
keystroke "j" using {command down}
repeat until exists (first window whose subrole is "AXSystemFloatingWindow")
delay 0.1
end repeat
end if
tell (first window whose subrole is "AXSystemFloatingWindow") to tell first group
get value of slider 1 # To get the value in use in a window using default spacing
set value of slider 1 to 10.0
end tell
keystroke "j" using {command down}
end tell