从 OS X 上的 Chrome 获取最前面标签的 URL?

编程入门 行业动态 更新时间:2024-10-24 18:21:17
本文介绍了从 OS X 上的 Chrome 获取最前面标签的 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有没有办法对 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 14:59:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最前面   标签   OS   Chrome   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!