推出Chrome的Applescript(具体细节)

时间:2013-06-05 19:21:30

标签: macos google-chrome applescript

我真的很难创建一些在osx上启动浏览器窗口(chrome)的方法,其中包括窗口大小,没有标签等特定内容。传统上我通过Windows使用vb脚本这是一个非常简单的练习但我会第一个承认,当涉及到mac时,我非常挣扎。

所以这是我的愿望清单。

我需要能够打开一个窗口(理想情况下是chrome,但除了safari之外的任何其他浏览器),没有状态栏,没有给定URL的地址栏和特定的窗口大小。我使用do javaScript在safari中管理了一些东西,并使用执行javascript和'window.open'尝试使用chrome,但这种情况不断失败...

帮助!

1 个答案:

答案 0 :(得分:23)

我没有找到任何方法来隐藏Chrome中的工具栏,但尝试使用这些脚本:

tell application "Google Chrome"
    open location "http://example.com"
    tell window 1 to enter presentation mode
end tell
tell application "Google Chrome"
    tell (make new window)
        set URL of active tab to "http://example.com"
        set bounds to {0, 22, 1200, 900}
    end tell
    activate
end tell
tell application "Safari"
    make new document with properties {URL:"http://example.com"}
    tell window 1
        set bounds to {0, 22, 1200, 900}
    end tell
    activate
end tell
tell application "System Events" to tell process "Safari"
    tell menu "View" of menu bar 1
        if exists menu item "Hide Toolbar" then click menu item "Hide Toolbar"
        if exists menu item "Hide Status Bar" then click menu item "Hide Status Bar"
        if exists menu item "Hide Tab Bar" then click menu item "Hide Tab Bar"
        if exists menu item "Hide Bookmarks Bar" then click menu item "Hide Bookmarks Bar"
    end tell
end tell