I'm trying to update an icon positioner script that I posted on MacScripters several years ago.
I've got two 'be nice if I could' problems....
1. Is it possible in Applescript to determine if the desktop or a window is the Finders focus?
2. In the script below (condensed from my whole script), organizing information of 30 selected icons on the desktop takes 1 second! Doing the same for 30 selected icons in a window takes 106 seconds, far too slow. Is there any way of using a shell script to both create a list of the selected icons, and getting the position of the icons? I note that when doing this for a finder window, the disk thrashes a bit, so it might not be possible to speed it up.
tell application "Finder"
set KeepDate to current date
set KeepSelection to the selection
set thelist to the KeepSelection as list
set ListLength to count of thelist
set FoundDisk to false
set xx to ListLength
repeat with x from 1 to ListLength
if kind of item x of thelist as text ≠ "Volume" then
set xx to x
if FoundDisk then exit repeat
else
set FoundDisk to true
set KeepDisk to item x of thelist as alias
if xx < ListLength then exit repeat
end if
end repeat
set ThisItem to item xx of thelist
try
set we_are_on_desktop to ((container of ThisItem as alias) is (path to desktop folder))
on error
set we_are_on_desktop to (kind of ThisItem as text = "Volume") --< only Volume icons selected
end try
set XYlist to {}
set Xdifflist to {}
set ydiffList to {}
if we_are_on_desktop then
repeat with ThisItem from 1 to ListLength
set temp to desktop position of item ThisItem of thelist
set {end of XYlist, end of Xdifflist, end of ydiffList} to {temp, item 1 of temp, item 2 of temp}
end repeat
else
repeat with ThisItem from 1 to ListLength
set temp to position of item ThisItem of thelist
set {end of XYlist, end of Xdifflist, end of ydiffList} to {temp, item 1 of temp, item 2 of temp}
end repeat
end if
say (current date) - KeepDate as text
end tell