【问题标题】:Error number -128 Applescript错误号 -128 Applescript
【发布时间】:2013-08-13 22:20:24
【问题描述】:

我有一个简单的苹果脚本,可以打开 Safari,打开网页 100 次(长篇故事),然后等待 300 秒关闭 Safari。

代码如下:

set theURL to "https://sites.google.com"



tell application "Safari"

    activate

    repeat 100 times

        try

            tell window 1 to set current tab to make new tab --with properties {URL:theURL}

            set URL of document 1 to theURL

        on error

            open location theURL



        end try

    end repeat


end tell

delay 300

tell application "Safari"
    quit
end tell

脚本的第一部分运行良好。当我通过延迟时,我收到一个错误:

错误“Safari 出现错误:用户已取消。”数字-128

我试图在不打开多个网页的情况下运行它只需激活 Safari,等待 10 秒然后退出。我遇到同样的问题。

有人处理过吗?

【问题讨论】:

    标签: applescript


    【解决方案1】:

    我没有收到您描述的错误。但是,如果在我运行代码时应用程序尚未运行,我会看到 Safari 未激活的错误。

    此代码似乎可以按您的预期工作...

    set theURL to "https://sites.google.com"
    
    tell application "Safari" to activate
    
    tell application "Safari"
        activate
    
        repeat 2 times
            try
                tell window 1 to set current tab to make new tab
                set URL of document 1 to theURL
            on error
                open location theURL
            end try
        end repeat
    end tell
    
    delay 5
    
    tell application "Safari"
        quit
    end tell
    

    【讨论】:

    • 我在 Safari 不运行时运行它。我认为我遇到的问题是当我尝试关闭时所有页面都没有打开。我将不得不重新考虑这个过程,也许打开一个页面,关闭它并重复该功能。
    猜你喜欢
    • 1970-01-01
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多