Re: How to move icons on desktop
Re: How to move icons on desktop
- Subject: Re: How to move icons on desktop
- From: Chris Nebel <email@hidden>
- Date: Fri, 29 Dec 2000 23:25:23 -0500
- Organization: Apple Computer, Inc.
Stephen Lanza wrote:
>
I had a script that moved a disk icon to a specific position on the
>
desktop which stopped working in MacOS 9. I recorded a script to see
>
what was going on and, when it is run, it fails.
>
>
The script code is:
>
>
tell application "Finder"
>
activate
>
get window {1230, 493}
>
select disk "RAM Disk"
>
set position of selection to {1219, 91}
>
end tell
>
>
The error I get is:
>
Finder got an error: Can't get window {1230, 493}
>
>
If I remove the get window statement, it still fails with: Finder got
>
an error: This window is the wrong kind (e.g. pop-up vs. normal) to use
>
this command.
Well, the "get window" statement is completely bogus, so the Finder is
correct in giving you an error there. You can identify Finder windows by
name or index, but not by position.
As for the "wrong type" error, most likely you've got "snap to grid"
turned on for the desktop. This is a known bug in the Mac OS 9 Finder --
it won't let you set the position of icons in a gridded or
always-arranged window, and gives you a really odd error when you try.
There are three possible workarounds:
1. Turn off "always snap to grid" for the appropriate window, in your
case, the desktop.
2. Change the script to use "set bounds" instead of "set position". You
have to specify a rectangle in that case, so it's four numbers instead of
two, but the Finder only pays attention to the first two. (E.g., "set
bounds of selection to {1219, 91, 0, 0}")
3. Wait for the next Mac OS update, which, as far as I know, fixes this
bug.
--Chris Nebel
AppleScript Engineering