我将以这样一个事实为前提,即我是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之前再次发送两条消息。
我在这里犯了一个基本错误吗?
I'll preface this with the fact that I'm new to applescript...
I have iChat set up to run this script whenever a new message is received:
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 fromThis works as expected an MyApp (which I'm coding) receives two strings (the handle of the buddy and the message content). The only trouble is that this script only seems to work once at least one message has been received in iChat. I.e the script seems to only work from the second message onwards. If the buddy logs out, he'll have to send two messages again before my app receives the AppleEvent.
Am I making a basic mistake here?
最满意答案
第一条消息实际上是“文本邀请”,因此您的通知脚本将需要另一个处理程序:
on received text invitation theMessage from theBuddy for theChat -- your tell app statement goes here end received text invitationThe first message is actually a "text invitation" so your notification script will need another handler:
on received text invitation theMessage from theBuddy for theChat -- your tell app statement goes here end received text invitation更多推荐
发布评论