【发布时间】:2011-07-31 19:27:32
【问题描述】:
我想测量一个窗口的大小和位置,包括它的抽屉。我已经找到了如何获取 first 抽屉的大小/位置,但是我找不到访问其他抽屉的方法(Google 也没有尝试)。您可以通过以下方式访问第一个抽屉:
tell application "System Events"
set appProcess to the first process whose name is "DrawerTest"
set appWindow to the first window of appProcess
if (count drawers of appWindow) > 0 then
set {{w, h}} to size of drawer of appWindow
set {{x, y}} to position of drawer of appWindow
set drawerBounds to {x, y, x + w, y + h}
end if
end tell
drawerBounds
如果我写first drawer 或drawer 1,我会收到错误Execution Error: Can’t get item 1 of 116.(最后一个数字不同)和Error -1728.(有时似乎不同,-1719 也有)。如果我不能写 first 或 1 我不能写 second 或 2 (产生相同的错误)。但是,我确信有办法,因为我可以访问第一个抽屉。有什么想法吗?
PS:出于测试目的,我创建了一个简单的应用程序,它只包含一个带有 4 个按钮的窗口,用于触发每个边缘的抽屉。 I pushed it to github,所以你可以克隆它并自己玩。
【问题讨论】:
标签: applescript drawer