要使用AppleScript告诉Chrome窗口1在Chrome窗口2中将鼠标下的链接作为选项卡打开,可以按照以下步骤进行操作:
tell application "Google Chrome"
activate
set windowList to every window
set tabList to {}
repeat with currentWindow in windowList
set tabList to tabList & tabs of currentWindow
end repeat
-- 检查窗口数量
if (count of windowList) < 2 then
display dialog "至少需要两个Chrome窗口来执行此操作。"
return
end if
-- 获取鼠标下的链接URL
tell application "System Events"
set mousePosition to position of the mouse
set frontmostApp to name of first application process whose frontmost is true
tell process frontmostApp
set linkURL to value of attribute "AXURL" of (first UI element whose position is mousePosition)
end tell
end tell
-- 在窗口2中打开链接
set targetWindow to item 2 of windowList
tell targetWindow
make new tab with properties {URL:linkURL}
end tell
end tell
这个脚本将获取鼠标下的链接URL,并将其作为选项卡打开在第二个Chrome窗口中。请注意,如果没有至少两个Chrome窗口打开,脚本将显示一个对话框提示您需要至少两个窗口才能执行操作。