2010-06-19 69 views
0

我認識到Google Chrome & Chromium尚未啓用AppleScript。但是,我想知道是否有辦法使用「系統事件」來隱藏特定的窗口或標籤?通過AppleScript隱藏鉻窗口

這裏是我迄今爲止...

tell application "System Events" 
tell process "Google Chrome" 
    repeat with theWindow in windows 
     set thePageName to title of theWindow 
     if thePageName contains "ABC" then 
      -- HIDE theWindow command here 
     end if 
    end repeat 
end tell 

末告訴

我可以訪問我想隱藏卻找不到命令實際上隱藏的窗口。

此外,如果有一種方法可以通過窗口中的選項卡重複,那會更好。

謝謝

回答

1

系統事件可以爲您鍵入鍵盤命令。因此,查看應用程序的菜單項並查看是否有任何鍵盤快捷鍵可以執行您想要的操作。例如,每個應用程序應該有一個「窗口」菜單。在「窗口」菜單中是一個「最小化」命令,其鍵盤快捷鍵爲「cmd-m」。所以你可以使用這個快捷鍵來隱藏你的窗口。只需將「 - 在這裏隱藏窗口命令」替換爲...

keystroke "m" using command down 

另一件事。爲此,在執行此操作之前,您必須確保應用程序是最前面的,因此請將以下內容添加到腳本的開頭。

tell application "Google Chrome" to activate