从 OS X 上的 Chrome 获取最前面标签的 URL? [英] Get the URL of the frontmost tab from Chrome on OS X?

查看:24
本文介绍了从 OS X 上的 Chrome 获取最前面标签的 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法对 Chrome 执行此操作?

Is there a way to do this to Chrome?

tell application "Google Chrome"
 return URL of front document as string
end tell

...不起作用.

推荐答案

由于没有 applescript 支持,所以只能通过 GUI 脚本来完成,我不确定您对 applescript 有多熟悉,但 gui 脚本是一个不好的做法.所以请谨慎使用此代码.同样重要,您可以访问在您的通用访问首选项中启用的辅助设备.

Since there is no applescript support the only way it can be done is through GUI scripting, I'm not sure how familiar you are with applescript but gui scripting is a bad practice to get into. so take this code with caution. it is also important that you have access for assistive devices ENABLED in your Universal Access preferences.

  tell application "Google Chrome"
    activate
    tell application "System Events"
        tell application process "Google Chrome"
            get value of text field 1 of tool bar 1 of window 1
        end tell
    end tell
  end tell

这篇关于从 OS X 上的 Chrome 获取最前面标签的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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