如何在收到消息之前运行applescript

时间:2015-07-17 04:01:17

标签: macos applescript imessage

我想从命令行运行一个applescript脚本,并在其中运行一个循环,直到收到一条消息。我正在使用以下方法收到消息时更新变量:

using terms from application "Messages"
    on message received theMessage from targetBuddy
        set gotMessage to true
    end message received
end using terms from

但是,当我将其放在on run区块内时,我在on message received处收到错误,说“预期”结束“但是找到”“。”当我将它放在运行块之外时,脚本可以保存并运行,但是没有调用on message message处理程序,我通过在那里抛出log语句来检查。如何在运行另一个循环时让脚本检查正在接收的消息?

1 个答案:

答案 0 :(得分:0)

您无法在应用程序外部运行应用程序事件处理程序,因为事件处理程序需要具有AppleScript脚本定义(字典)的目标进程来注册事件并将apple事件发送到。

相关问题