通过Applescript获取iChat消息的内容(Get contents of iChat message via Applescript)

编程入门 行业动态 更新时间:2024-10-25 16:22:27
通过Applescript获取iChat消息的内容(Get contents of iChat message via Applescript)

我将以这样一个事实为前提,即我是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 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?

最满意答案

第一条消息实际上是“文本邀请”,因此您的通知脚本将需要另一个处理程序:

on received text invitation theMessage from theBuddy for theChat -- your tell app statement goes here end received text invitation

The 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

更多推荐

本文发布于:2023-04-27 16:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   内容   iChat   Applescript   contents

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!