如何在OS X中获取桌面上图标的位置?或者,如何获取桌面上所有图标及其位置的列表?
答案 0 :(得分:4)
试试这个AppleScript代码
tell application "Finder"
get desktop position of every item of desktop
end tell
答案 1 :(得分:1)
文件夹的解决方案是use a catalog iterator,以获取文件夹中每个项目的Finder信息。 Finder信息是FileInfo或FolderInfo结构,其中包含QuickDraw Point
(整体坐标,原点左上角,正y下),指定图标的显示位置。
我不知道你将如何为桌面做这件事。 Home文件夹中有一个Desktop文件夹,但检查其内容可能会获取Finder用于在窗口中显示该文件夹的位置。它也可能不包括桌面文件夹中没有的任何“桌面”,例如已安装的卷。
答案 2 :(得分:0)
以下苹果脚本将获得这些位置(使用脚本桥或NSAppleScript)
tell application "Finder"
tell every item of desktop
get position
get name
end tell
end tell
答案 3 :(得分:0)
另一个解决方案(非常类似于@Vaskravchuk)
tell application "Finder"
repeat with anItem in desktop
get {desktop position, name} of anItem
end repeat
end tell