Applescript:拉开边界记录

Applescript: pulling apart a bounds record

我最近降级到 El Capitan,Finder 关于新 window 的大小和位置的想法让我抓狂。

所以,我想写一个 applescript 来保留 window 的左坐标,将顶部设置得尽可能高,并将宽度和高度设置为特定值。

我可以得到边界:

tell application "Finder"
  set theBounds to bounds of front window
end tell

但是如果我要求 left of theBounds 我得到一个错误。

Applescript 肯定提供了一种解压 bounds?

的方法

边界 属性 returns 类型 rectangle。这只是四个整数值的列表,代表左上点的 x/y 坐标和右下点的 x/y 坐标。也许这个小脚本更清楚:

tell application "Finder"
    set {x1, y1, x2, y2} to bounds of front window
    set {winWidth, winHeight} to {x2 - x1, y2 - y1}
end tell

你可以用同样的方法设置坐标。定义左上点的x和y,将你的目标宽度加到x1,目标高度加到y1,得到第三个和第四个值。

祝你有愉快的一天,迈克尔/汉堡