【问题标题】:Get contents of iChat message via Applescript通过 Applescript 获取 iChat 消息的内容
【发布时间】:2011-06-19 04:03:42
【问题描述】:

我会以我是 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 message received theMessage from the buddy for theChat”仅在第二条消息时调用
  • 这很烦人。有解决办法吗?

标签: applescript ichat


【解决方案1】:

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

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

【讨论】:

  • 谢谢!这解决了问题。我添加了新的处理程序并告诉 iChat 在文本邀请上也运行脚本。上一个答案很有帮助,我已经为你标记了。
猜你喜欢
  • 2012-03-08
  • 1970-01-01
  • 2021-04-19
  • 1970-01-01
  • 1970-01-01
  • 2021-01-28
  • 2013-04-02
  • 2016-11-15
相关资源
最近更新 更多