Re: Change the Position of an disk icon on the desktop
Re: Change the Position of an disk icon on the desktop
- Subject: Re: Change the Position of an disk icon on the desktop
- From: Paul Skinner <email@hidden>
- Date: Sat, 4 Oct 2003 13:20:48 -0400
On Friday, October 3, 2003, at 06:57 PM, Walter Ian Kaye wrote:
At 03:25p -0700 10/03/2003, Christopher Nebel didst inscribe upon an
electronic papyrus:
On Oct 3, 2003, at 12:25 PM, Michael Slomski wrote:
set thePos to position of disk 1
will get values which are not the position of items on my desktop
but of the window of the desktop folder in users.
Changing positions will change the location of the items in that
window, but not on the desktop itself (OS X 10.2.8). Perhaps it is
fixed in Panther or broken with the .8 Update?
No, that is working as designed, as they say. There was an HI
decision made some time ago that icon positions on the desktop and
icon positions in the window of the desktop folder should be
independent,
That is understandably logical...
and the scripting property reflects this: "position" refers only to
the position in the window.
...although the usefulness of that is pretty small compared to the
usefulness of the position on the actual desktop.
Not to mention that one of the first things a new scripter wants to do
is RECORD positioning icons on their desktop. They achieve neither.
There is currently no way to set the desktop position of an item,
though there is a bug filed on that.
Where does it stand priority-wise?
Do you know where the Finder records the desktop positions? Is it
possible to set up a brute force method while we await the finishing
of the Finder? (And when are those "not available yet" dictionary
entries going to be addressed?)
thanks,
-Walter
I believe the positioning on the desktop is probably stored in the
inscrutable .DS_Store file. A guess.
You can work around the lack of desktop positioning of icons if you've
got GUI scripting installed. It's not a hack though! It's a collection
of hacks. :P
Run the script below. Try setting the custom background of the
resulting window to match your desktop image. Try closing it, try
minimizing then expanding it. Wierd stuff, try changing the 11th line
to...
'set current view of the desktopReference to column view'
Now try naving with your arrow keys. Whee!
This script fails repeatedly after one successful run if saved as an
app, but runs consistently in SD 3. Anyone spot why?
Mind the wrap.
set {h, w} to ScreenDimensions()
tell application "Finder"
set background to desktop picture as alias
activate
set the desktopFolder to (path to desktop folder from user domain)
open the desktopFolder
set the desktopReference to a reference to container window of the
desktopFolder
set the bounds of desktopReference to {(h / 4), (w / 4), ((h / 4) *
3), ((w / 4) * 3)}
set current view of the desktopReference to icon view
--set the desktop picture of desktopReference to background--Not yet
supported by AppleScript.
set desktopItems to items of the desktopReference
my HideToolBar(desktopReference)
my ScaleWindowToFullScreen(desktopReference, h, w)
repeat with thisItem in desktopItems
my twirl(thisItem)
end repeat
my twirl(desktopReference)
end tell
on ScreenDimensions()
set previousTIDs to AppleScript's text item delimiters --Store the
TIDs' initial value.
try
set output to {(word 3 of (do shell script "defaults read
/Library/Preferences/com.apple.windowserver | grep -w Width")) as
number, (word 3 of (do shell script "defaults read
/Library/Preferences/com.apple.windowserver | grep -w Height")) as
number}
set AppleScript's text item delimiters to previousTIDs --Restore the
TIDs to their initial value.
return the output
on error errorMessage number errorNumber partial result errorResult
from errorFrom to ErrorTo
set AppleScript's text item delimiters to "" --Modify unhandled
errors to include the class and name of this object.
set errorMessage to ("The " & (class of ScreenDimensions) & " '" &
"ScreenDimensions" & "' generated an error." & return & the
errorMessage) as text
set AppleScript's text item delimiters to previousTIDs
error errorMessage number errorNumber partial result errorResult from
errorFrom to ErrorTo
end try
end ScreenDimensions
on ScaleWindowToFullScreen(finderItemReference, h, w)
tell application "System Events"
if exists menu item "Hide Status Bar" of menu "View" of menu bar 1 of
application process "Finder" then
set yOrigin to 0 --Hide the status bar off-screen behind the Menu
bar.
else
set yOrigin to 22 --Align the top of the window with the bottom of
the Menu bar
end if
end tell
set {h, w} to {h + 15, w + 15} --push the scroll bars off-screen.
set incr to 3
tell application "Finder"
set {x1, y1, x2, y2} to bounds of finderItemReference
end tell
set {x1s, y1s, x2s, y2s} to {(x1 / incr), (y1 / incr), (h - x2) /
incr, (w - y2) / incr}
set sizeList to {}
repeat with i from 1 to incr
set sl to {(x1 - x1s), (y1 - y1s), (x2 + x2s), (y2 + y2s)}
set the end of sizeList to {sl}
end repeat
sizeList
tell application "Finder"
repeat with i from 1 to incr
set the bounds of finderItemReference to item i of sizeList
end repeat
set the bounds of finderItemReference to {0, yOrigin, h, w}
end tell
end ScaleWindowToFullScreen
on HideToolBar(desktopReference)
if my toolbarVisible(desktopReference) then
my toggleToolbar(desktopReference)
end if
end HideToolBar
on toolbarVisible(windowReference)
--The toolbar visibility isn't yet ascertainable from applescript.
--So I measure the window and toggle the setting and compare the new
size. :P
tell application "Finder"
activate
set a to bounds of windowReference
my toggleToolbar(windowReference)
set b to bounds of windowReference
set toolbarVisible to ((item 4 of a) > (item 4 of b))
my toggleToolbar(windowReference)
return toolbarVisible
end tell
end toolbarVisible
on toggleToolbar(windowReference)
tell application "System Events"
tell process "Finder"
activate
click (the first button of the front window whose subrole is
"AXToolbarButton")
end tell
end tell
end toggleToolbar
on twirl(ItemReference)
tell application "Finder"
activate
set {centerx, centery} to position of ItemReference
end tell
set steps to 6
set radius to 30
set phi to 0
repeat while phi < steps
set phi to phi + pi / steps
set x to centerx + radius * (cos (phi))
set y to centery + radius * (sin (phi))
tell application "Finder"
activate
set position of ItemReference to {x, y}
end tell
end repeat
tell application "Finder"
set position of ItemReference to {centerx, centery}
end tell
end twirl
PS
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.