通过Applescript获取iChat消息的内容

发布于 2024-10-15 09:12:58 字数 578 浏览 2 评论 0原文

我将以此为序言,我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

网名女生简单气质 2024-10-22 09:12:58

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文