如何在不同位置创建两个新的 Safari windows?
How do I create two new Safari windows in different positions?
我正在尝试编写一个脚本,它可以在桌面上的不同位置打开两个具有不同边界的 Safari windows,如下所示:
{像素宽,像素高}标签比框的实际比例更准确。我遇到的问题是我可以完全按照我想要的方式设置左侧 window 的边界 - 因为它是脚本生成的第一个 - 但是当我尝试指定第二个 window 在右边,它的位置与第一个 window 的位置相关联,并且它要么被限制在第一个 window 的范围内,要么 - 如果我告诉它到 "spawn"在第一个 window 的边界之外 - 根本没有出现。
# Desktop: {1280, 800}
tell application "Safari"
activate
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 550, 750}
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 700, 750}
end tell
如您所见,脚本目前在同一个 {25, 25} 坐标处创建两个 windows,因为这是我所拥有的最接近我想要的功能版本。
如何设置右侧第二个 window 的边界,使其如图所示,而不考虑左侧第一个 window 的边界?
bounds
属性的值作为四项返回 屏幕[=55]window的边界区域的整数列表 =]:
- 列表项 1: {
x1
, y1, x2, y2}
- 从屏幕左侧到 window 左侧的距离(以像素为单位)。
- 列表项 2: {x1,
y1
, x2, y2}
- 从屏幕顶部到 window 顶部的距离(以像素为单位)。
- 列表项 3: {x1, y1,
x2
, y2}
- 从屏幕左侧到 window 右侧的距离(以像素为单位)。
- 列表项 4: {x1, y1, x2,
y2
}
- 从屏幕顶部到 window 底部的距离(以像素为单位)。
第一个 window 的 bounds
宽度为 550,高度为 750,偏移量为 25 像素:
{25, 25, 575, 775}
第二个window的bounds
,宽700,高750,与第一个之间没有space window 将是:
{575, 25, 1275, 775}
这将为您提供图表中显示的两个 windows 大小,但间距与显示的不完全相同。
tell application "Safari"
activate
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 575, 775}
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {575, 25, 1275, 775}
end tell
我正在尝试编写一个脚本,它可以在桌面上的不同位置打开两个具有不同边界的 Safari windows,如下所示:
{像素宽,像素高}标签比框的实际比例更准确。我遇到的问题是我可以完全按照我想要的方式设置左侧 window 的边界 - 因为它是脚本生成的第一个 - 但是当我尝试指定第二个 window 在右边,它的位置与第一个 window 的位置相关联,并且它要么被限制在第一个 window 的范围内,要么 - 如果我告诉它到 "spawn"在第一个 window 的边界之外 - 根本没有出现。
# Desktop: {1280, 800}
tell application "Safari"
activate
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 550, 750}
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 700, 750}
end tell
如您所见,脚本目前在同一个 {25, 25} 坐标处创建两个 windows,因为这是我所拥有的最接近我想要的功能版本。
如何设置右侧第二个 window 的边界,使其如图所示,而不考虑左侧第一个 window 的边界?
bounds
属性的值作为四项返回 屏幕[=55]window的边界区域的整数列表 =]:
- 列表项 1: {
x1
, y1, x2, y2}- 从屏幕左侧到 window 左侧的距离(以像素为单位)。
- 列表项 2: {x1,
y1
, x2, y2}- 从屏幕顶部到 window 顶部的距离(以像素为单位)。
- 列表项 3: {x1, y1,
x2
, y2}- 从屏幕左侧到 window 右侧的距离(以像素为单位)。
- 列表项 4: {x1, y1, x2,
y2
}- 从屏幕顶部到 window 底部的距离(以像素为单位)。
第一个 window 的 bounds
宽度为 550,高度为 750,偏移量为 25 像素:
{25, 25, 575, 775}
第二个window的bounds
,宽700,高750,与第一个之间没有space window 将是:
{575, 25, 1275, 775}
这将为您提供图表中显示的两个 windows 大小,但间距与显示的不完全相同。
tell application "Safari"
activate
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {25, 25, 575, 775}
make new document with properties {URL:"https://www.google.com"}
set bounds of front window to {575, 25, 1275, 775}
end tell