启动 Chrome 的 Applescript(详细信息) [英] Applescript to Launch Chrome (with specifics)

查看:29
本文介绍了启动 Chrome 的 Applescript(详细信息)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很难在 osx 上创建一些在 osx 上启动浏览器窗口 (chrome) 的方法,具体包括窗口大小、无选项卡等.传统上,我通过带有 IE 的窗口使用 vb 脚本,这是一个非常简单的练习但我会第一个承认,说到 mac,我很挣扎.

I'm really struggling with creating some method of launching a browser window (chrome) on osx with specifics such as window size, no tabs etc. Traditionally I've used vb script through windows with IE which is a pretty simple exercise but I'll be the first to admit, when it comes to macs I struggle greatly.

这是我的愿望清单.

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

I need to be able to open a window (ideally in chrome, but any other browser except safari), that has no status bar, no address bar with a given URL, and a specific window size. I did manage something in safari using do javaScript, and attempted the same with chrome using execute javascript and 'window.open' but this failed continually...

帮助!

推荐答案

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

I didn't find any way to hide the toolbar in Chrome, but try something like these scripts:

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

这篇关于启动 Chrome 的 Applescript(详细信息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆