使用Applescript将Active Finder选项卡打开到新窗口

时间:2014-04-05 22:05:30

标签: applescript

我正在尝试编写一个AppleScript来将活动的Finder选项卡分解为一个新窗口。我可以使用Chrome执行此操作:

on moveActiveTabToNewWindow()
  tell application "Google Chrome"
    set theURL to URL of active tab of window 1
    close active tab of window 1
    make new window
    set URL of active tab of window 1 to theURL
  end tell
end moveActiveTabToNewWindow

但是,据我所知,Finder选项卡无法通过Applescript访问。这可能吗?我是OS X Mavericks 10.9.2。

1 个答案:

答案 0 :(得分:2)

无法直接访问操纵标签,但您可以手动执行此操作。换句话说,我们可以关闭该标签,然后打开一个新窗口并复制您在该标签中看到的内容,就像您在Google Chrome示例中所做的那样。

这是一些代码。这段代码很基本。就像我从Finder窗口获得“目标”属性一样,您也可以获得其他属性并在新窗口中复制它们以真正完成复制选项卡的更完整工作。您可能希望至少复制边界和视图选项。

祝你好运。

-- get the target of the front tab
tell application "Finder"
    activate
    tell window 1 to set t to target
end tell

-- close that tab
tell application "System Events"
    keystroke "w" using command down
end tell

-- make a new window and set its target
tell application "Finder"
    set w to make new Finder window at front
    tell w to set target to t
end tell