macos - Applescript 将启动 Chrome(具体内容)

标签 macos google-chrome applescript

我真的很难创建一些在 osx 上启动浏览器窗口(chrome)的方法,具体细节包括窗口大小、没有选项卡等。传统上,我通过带有 IE 的窗口使用 vb 脚本,这是一个非常简单的练习但我首先要承认,当谈到 Mac 时,我遇到了很大的困难。

这是我的愿望 list 。

我需要能够打开一个窗口(最好是在 chrome 中,但也可以在除 safari 之外的任何其他浏览器中),该窗口没有状态栏、没有带有给定 URL 的地址栏以及特定的窗口大小。我确实使用 do javaScript 在 safari 中管理了一些东西,并尝试使用执行 javascript 和 'window.open' 在 chrome 中进行相同的操作,但这不断失败......

救命!

最佳答案

我没有找到任何方法来隐藏 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

关于macos - Applescript 将启动 Chrome(具体内容),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948093/

相关文章:

javascript - 为什么模糊和聚焦在 Safari 上不起作用?

html - Chrome 53 中的 <select> 高度

file - 在 AppleScript 中获取文件的最后修改日期

bash - 带有 bash 和 applescript 的字符串文字

vba - 如何使用 Apple 脚本访问 Powerpoint(Mac 版)的对象事件?

c++ - 是否有可能让 Visual Studio 2017 将 c++ 代码编译成 exe 以外的文件类型?

c++ - 在样本外使用 libaws 时返回随机字符

javascript - Chrome 扩展 - 与外部程序通信

javascript - Chrome 扩展按钮

c - 无法重命名匿名声明 - Xcode 7.1.1