【问题标题】:Break Active Finder Tab Into New Window with Applescript使用 Applescript 将 Active Finder 选项卡拆分为新窗口
【发布时间】:2014-04-05 22:05:29
【问题描述】:

我正在尝试编写一个小程序来将活动的 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。

【问题讨论】:

    标签: applescript


    【解决方案1】:

    无法直接访问操作选项卡,但您可以手动操作。换句话说,我们可以关闭该选项卡,然后打开一个新窗口并复制您在该选项卡中看到的内容,就像您在 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
    

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 2016-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多