【问题标题】:How to Handle Automator Errors with Applescript如何使用 Applescript 处理 Automator 错误
【发布时间】:2013-08-02 13:00:19
【问题描述】:

我还是个新手,所以我希望我的问题是有道理的。

我创建了一个简单的 Automator 应用程序。我已将 iCal 设置为在夜间运行它。因为其他的东西同时在运行,我有时会得到“动作‘blah blah blah’遇到错误....”

有没有办法(使用 Applescript):(1) 忽略错误并让应用程序继续运行或 (2) 单击错误上的“确定”按钮并重新启动应用程序?

编辑:我基本上希望 Applescript 运行 Automator 创建的应用程序,并且,如果/当该应用程序具有“操作“等等等等”遇到错误”类型消息时,我想要Applescript 继续或重新启动 Automator 创建的应用程序。这包括消除在运行 Automator 创建的应用程序期间弹出的错误消息框。

谢谢。

【问题讨论】:

    标签: applescript automator


    【解决方案1】:

    如果您的代码在 Applescript 中,您可以尝试以下方式:

    repeat with i from 1 to 5
        try
            --insert your code here
            set thrownError to 1 / 0
    
            -- If code completes without error, exit repeat
            exit repeat
        on error
            beep
            delay 3
        end try
    end repeat
    

    【讨论】:

    • 抱歉,代码不在 Applescript 中。该应用程序是在 Automater 中创建的(基本上是多个 Watch Me Dos 和循环)。每当某些事情延迟了应用程序正在执行的操作时,我都会收到“遇到错误”消息。当我的计算机尝试执行多项操作时,我基本上会收到错误消息。我正在寻找一种方法来使用 Applescript 来消除弹出错误消息,并在发生这种类似超时的错误时重新启动 Automater 创建的应用程序。再次感谢。
    • 尝试将 Watch me do 中的操作拖到工作流中,这将创建一个 Applescript 并包含在 try 块中。
    • @adayzdone,哦,这很有趣! user2475147,您可以尝试将超时设置为更高的级别。超时的持续时间是“Watch Me Do”操作中的设置。无论如何,这里还有一个指向 GUI 脚本页面的链接:learnbymac.com/wiki/…
    【解决方案2】:

    如果您只想忽略 applescript 中的错误,只需使用 try

    try
      --do what ever
    on error
      --continue with code
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-12
      • 1970-01-01
      • 2014-02-18
      • 1970-01-01
      相关资源
      最近更新 更多