通过Applescript获取iChat消息的内容

我将以这样一个事实为前提,即我是Apple的新手...... 我有iChat设置为每当收到新消息时运行此脚本:
using terms from application "iChat"

    on message received theMessage from theBuddy for theChat

        set theHandle to handle of theBuddy

        tell application "MyApp"
            receivedInstantMessage from theHandle message theMessage
        end tell

    end message received

end using terms from
这按预期工作,MyApp(我正在编码)接收两个字符串(伙伴的句柄和消息内容)。唯一的麻烦是这个脚本似乎只在iChat中收到至少一条消息后才能工作。即,脚本似乎只能从第二个消息开始工作。如果好友退出,他必须在我的应用收到AppleEvent之前再次发送两条消息。 我在这里犯了一个基本错误吗?     
已邀请:
第一条消息实际上是“文本邀请”,因此您的通知脚本将需要另一个处理程序:
on received text invitation theMessage from theBuddy for theChat
  --  your tell app statement goes here
end received text invitation
    

要回复问题请先登录注册