2014-04-05 31 views
0

我正在嘗試編寫一個applescript來將活動的Finder選項卡打開到新窗口中。我能夠與Chrome瀏覽器做到這一點使用:將Active Finder選項卡分解爲具有AppleScript的新窗口

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 

然而,據我可以告訴搜索選項卡不通過AppleScript的訪問。這可能嗎?我在OS X Mavericks 10.9.2上。

回答

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 
相關問題