How can I get the position of an icon on the desktop in OS X? Or, how can I get a list of all icons on the desktop and their positions?
Try this AppleScript code
tell application "Finder"
get desktop position of every item of desktop
end tell
The solution for a folder is to use a catalog iterator to get the Finder info for every item in the folder. The Finder info is a FileInfo or FolderInfo structure that contains a QuickDraw Point
(integral co-ordinates, origin top-left, positive y down) specifying where the icon will appear.
I don't know how you would do this for the Desktop, though. There is a Desktop folder in the Home folder, but examining its contents will probably get you the positions that the Finder will use to display that folder in a window. It also will probably not include anything “on the Desktop” that isn't in the Desktop folder, such as mounted volumes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With