主要问题是Apple脚本编辑器不知道任何名称“ App”或“ App 2”,因此,如果您运行脚本,它将要求您选择App的存储位置,然后将“ App”替换为“ Apply”。应用程序。“应用程序2”也会发生这种情况。
因此,如果您两次选择相同的应用程序(根据您的提及,这就是您要尝试的操作),那么这两次都将删除名称为“ App”和“ App 2”的名称,且名称与实际应用程序相同。
或者,如果您将App用作应用程序实际名称的缩写,则它会在第一条语句中知道该应用程序,但在第二条语句中却不知道,因此它只会询问一次并仅替换“ App 2”。
要执行您想要的操作,我建议您将脚本更改为类似的内容,然后以这种方式尝试(未测试):
tell application "<Name of Application>" to activate --open first Window
tell application "<Name of Application>" to activate --open second Window
tell application "System Events" to tell application process "<Name of Application>"
set position of window 1 to {8, 22}
set position of window 2 to {914, 22}
end tell
如果这不起作用,则可以采用此脚本来并排移动两个打开的Finder Windows。
property monitor_width : 980
property monitor_height : 768
set the startup_disk to (path to startup disk)
tell application "Finder" activate
set visible of (every process whose visible is true and frontmost is false) to false
-- BOTTOM WINDOW
set this_window to make new Finder window
set the target of this_window to the startup_disk
set the bounds of this_window to {0, (monitor_height * 0.55) div 1, monitor_width, monitor_height}
set the current view of this_window to column view
-- TOP WINDOW
set this_window to make new Finder window
set the target of this_window to the startup_disk
set the bounds of this_window to {0, (monitor_height * 0.06) div 1, monitor_width, (monitor_height * 0.53) div 1}
set the current view of this_window to column view
end tell
来源:http://hints.macworld.com/article.php?story = 20011127022706921