【发布时间】:2019-06-17 22:55:17
【问题描述】:
我正在制作一个启动脚本来启动各种应用程序并设置它们的位置和大小。它适用于除 chrome 之外的所有内容。我需要一个脚本来检查 Chrome 是否打开,如果它打开当前窗口,如果它没有激活它。然后,设置它的大小和位置
-- Start terminal
tell application "Terminal"
if (exists window 1) then reopen
activate
do script "screenfetch"
end tell
delay .5
tell application "System Events" to tell process "Terminal"
tell window 1
set size to {960, 600}
set position to {2880, 0}
end tell
end tell
delay .5
-- Start Chrome
tell application "Google Chrome"
if (exists window 1) then
reopen
else
activate
end if
end tell
delay .5
tell application "System Events" to tell process "Google Chrome"
tell front window
set size to {960, 600}
set position to {1920, 0}
end tell
end tell
delay .5
这适用于终端。它启动一个终端并将其放在我的第二台显示器的右上角。但是,对于 Chrome,它会:说“找不到 Chrome 的 Window 1”,或者,它会将 chrome 放在前面,并且不会设置其大小或位置。
【问题讨论】:
标签: applescript