我想确定屏幕上MacOS底座中图标的x,y位置。这可能吗?我在XCode上玩过一些但是没有真正找到任何API来做到这一点,在线搜索没有产生任何有用的东西。也许那是因为我不确定要搜索什么,因为我不是一个非常有经验的MacOS开发人员。
我以为我会详尽无遗,只需打印出可用于停靠项目的所有属性和属性:
use application "System Events"
tell process "Dock" to tell list 1 to set dockItems to a reference to ¬
(every UI element whose role is "AXDockItem")
get the name of the dockItems
--> {"Safari", missing value, "Finder", "App Store", "Launchpad", "Safari", "Google",
--> "Spark", "Calendar", "Notes", "Photo Booth", "Photos", "Messages", "Telegram Desktop",
--> "WhatsApp", "iTunes", "Accessibility Inspector", "Script Editor", "System Preferences",
--> "Google Chrome", "Atom", "Automator", missing value, "CK", "WebCatalog Apps",
--> "Applications", "Trash"}
get the position of the dockItems
--> {{1435, 47}, {1435, 78}, {1435, 81}, {1435, 112}, {1435, 143}, {1435, 174},
--> {1435, 206}, {1435, 237}, {1435, 268}, {1435, 299}, {1435, 330}, {1435, 362},
--> {1435, 393}, {1435, 424}, {1435, 455}, {1435, 486}, {1435, 517}, {1435, 549},
--> {1435, 580}, {1435, 611}, {1435, 642}, {1435, 673}, {1435, 704}, {1435, 736},
--> {1435, 750}, {1435, 781}, {1435, 812}, {1435, 843}}
get the name of the attributes of ¬
some UI element in the dockItems
--> {"AXRole", "AXRoleDescription", "AXSubrole", "AXTitle", "AXParent", "AXChildren",
--> "AXPosition", "AXSize", "AXFrame", "AXTopLevelUIElement", "AXSelected",
--> "AXShownMenuUIElement", "AXStatusLabel", "AXProgressValue"}
get the properties of ¬
some UI element in the dockItems
--> {minimum value:missing value, orientation:missing value, position:{1435, 785}, class:UI element,
--> accessibility description:missing value, role description:"folder dock item",
--> focused:missing value, title:"WebCatalog Apps", size:{39, 30}, help:missing value,
--> entire contents:{}, enabled:missing value, maximum value:missing value, role:"AXDockItem",
--> value:missing value, subrole:"AXFolderDockItem", selected:false, name:"WebCatalog Apps",
--> description:"folder dock item"}
如果位置坐标让你失望,我应该说我的底座位于屏幕的右侧,并自动隐藏(我的屏幕宽度为1440)。