Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Applescript获取iChat消息的内容_Applescript_Ichat - Fatal编程技术网

通过Applescript获取iChat消息的内容

通过Applescript获取iChat消息的内容,applescript,ichat,Applescript,Ichat,我将以我是applescript新手这一事实作为开场白 我已将iChat设置为在收到新消息时运行此脚本: using terms from application "iChat" on message received theMessage from theBuddy for theChat set theHandle to handle of theBuddy tell application "MyApp" receive

我将以我是applescript新手这一事实作为开场白

我已将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

不,好像其他人也有这个问题。不知何故,“on message received theMessage from the buddy for the chat”只在第二条消息中调用,这非常烦人。有解决办法吗?谢谢!这就解决了问题。我添加了新的处理程序,并告诉iChat也在文本邀请上运行脚本。前面的答案很有帮助,我已经为您做了标记。