通过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"
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 from
This 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一条消息实际上是“文本邀请”,因此您的通知脚本将需要另一个处理程序:
The first message is actually a "text invitation" so your notification script will need another handler: