Applescript从Safari获取URL [英] Applescript to get the URL from Safari

查看:113
本文介绍了Applescript从Safari获取URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Safari获取URL,请关闭该标签并在Chrome中打开它(

I'm trying to get the URL from Safari, close the tab and open it in Chrome ( TUAW Post ) But I keep getting the error:

error "Safari got an error: Can’t get current tab." number -1728 from current tab

在代码行中:

set theURL to URL of current tab of window 1

有什么建议吗?

所有代码:

property theURL : ""

tell application "Safari"

    set t set theURL to URL of current tab of window 1
    close current tab

end tell

tell application "Google Chrome"

    set URL of active tab of window 1 to theURL

    activate

end tell

推荐答案

它对我有用...

tell application "Safari"
    set theURL to URL of current tab of window 1
end tell

您必须显示更多代码,因为该错误是由其他原因引起的.让我问您一个问题,您是否在另一个Tell块中包含了Tell应用程序Safari语句?也许它在告诉Google chrome的代码块中?如果是这样,请将其删除.

You have to show more code because the error is caused by something else. Let me ask you this, do you have the tell application Safari statement inside of another tell block? Maybe it's inside the tell google chrome block of code? If so remove it.

这篇关于Applescript从Safari获取URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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