dmd*_*dmd 12 applescript google-chrome
有没有办法对Chrome执行此操作?
tell application "Google Chrome"
return URL of front document as string
end tell
Run Code Online (Sandbox Code Playgroud)
......不起作用.
Gui*_*eau 42
现在Chrome(7+)支持AppleScript,您可以这样做:
tell application "Google Chrome"
get URL of active tab of first window
end tell
Run Code Online (Sandbox Code Playgroud)
注意:"第一个窗口"指的是最前面的窗口.
由于没有Applecript支持,唯一的方法就是通过GUI脚本编写,我不确定你对applecript有多熟悉,但gui脚本编写是一个不好的做法.所以请谨慎使用此代码.您还可以在Universal Access首选项中访问辅助设备,这一点非常重要.
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
Run Code Online (Sandbox Code Playgroud)
有一种更简单的方法来检索 URL。
'tell application "Google Chrome" to return URL of active tab of front window'
测试和工作就像一个魅力。
| 归档时间: |
|
| 查看次数: |
9135 次 |
| 最近记录: |