On 22/01/2011, at 10:07 AM, OzSanta wrote: G'day
Problem : I'm trying to update an applescript that automatically arranges icons.
Works fine for desktop icons EXCEPT those that are disk icons (kind = Volume ). These can be moved, but the positions (desktop position) stay the same even when re-moved manually.
eg. run the following script with the last line uncommented and a single desktop disk icon selected. Then move the disk icon to a new position. Comment out the line, and re-run with the same icon selected. The desktop position still shows as {600,100} even tho you've shifted the icon.
I've used several methods to refresh to desktop; none work to refresh the disk icon position.
Any advice please?
Regards
Santa
tell application "Finder" set ptd to path to desktop delete (make new folder at ptd) update desktop update (item 1 of (selection as alias as list)) properties of (item 1 of (selection as alias as list)) --set desktop position of (item 1 of (selection as list)) to {600, 100} end tell
Here's a better script that shows the problem. Select a disk icon and move it, then run the script. The icon should bounce back to it's original position.
tell application "Finder" set thecount to (count of (selection as list)) if thecount > 0 then set temp to (item 1 of (selection as alias as list)) set DiskFlag to ((kind of temp) = "Volume") if DiskFlag then select disk temp close window 1 set desktop position of disk temp to desktop position of disk temp properties of disk temp else say "please select a disk icon" end if else say "please select a disk icon" end if end tell
Here's a possible answer to the problem, but sometimes it doesn't work for some unfathomable reason.
tell application "Finder" set thecount to (count of (selection as list)) if thecount > 0 then set temp to (item 1 of (selection as alias as list)) set DiskFlag to ((kind of temp) = "Volume") if DiskFlag then quit delay 0.4 try activate end try select disk temp close window 1 set desktop position of disk temp to desktop position of disk temp properties of disk temp else say "please select a disk icon" end if else say "please select a disk icon" end if end tell
Anyone know a better way to reset the finder? Quitting is rather drastic!
Regards
Santa
|