mik*_*ike 9 applescript messages ichat
嘿我正在运行以下脚本:
using terms from application "Messages"
on message received this_message from this_buddy for this_chat
display dialog "test"
end message received
end using terms from
Run Code Online (Sandbox Code Playgroud)
但是当我收到消息时,我每次都会在消息中收到以下错误:
Event: Message Received in Active Chat
File: registerToReceiveMessages.applescript
Error: Error -1708
Run Code Online (Sandbox Code Playgroud)
我无法在互联网上找到任何错误.它似乎适用于除活动聊天之外的每个聊天.有任何想法吗?
此外,我正在尝试为"已收到的已发送消息"添加事件,但每次我编译applescript时都会将其替换为"已收到远程屏幕共享邀请"
每当您选择不处理指定事件的AppleScript时,您将收到错误-1708.
例如,如果您的脚本仅实现了on message sent,但是每次收到消息时都将此脚本设置为运行,则会收到错误-1708.这是因为您的脚本只知道如何处理传出消息,而不是传入消息,因此,错误-1708.
现在这里有点有趣......
如果您尝试使用默认脚本Mix Message Case.applescript的事件Message Received,Message Received in Active Chat和Message Sent.第一个和最后一个工作正常,但您将在活动聊天事件中收到-1708错误.我们可以推断出这意味着脚本没有处理事件Message Received in Active Chat.所以看起来即便是Apple也无法立即处理此事件.
OS X Mavericks更新:
此更新修复了前面提到的错误.如果您选择Apple的示例脚本Speak Events.applescript,您会注意到它可以完美地处理收到活动聊天室的消息.如果检查代码,您会注意到它正在使用该on active chat message received方法.我们现在可以在脚本中使用它.由于我不再安装旧版本,因此我无法测试此版本的相同方法是否有效.
以下是Speak Events.applescript的代码:
on active chat message received with eventDescription
say eventDescription
end active chat message received
Run Code Online (Sandbox Code Playgroud)
另请注意,您不再指定要针对特定事件运行的单个脚本.而是为Messages事件指定单个脚本处理程序.这意味着您必须实现所有事件以避免获得-1708方法.请注意,在示例脚本中,Apple甚至都有评论# The following are unused but need to be defined to avoid an error.这是一个模板,可以用作脚本的起点:
using terms from application "Messages"
# The following are unused but need to be defined to avoid an error
on message sent theMessage with eventDescription
end message sent
on message received theMessage with eventDescription
end message received
on chat room message received with eventDescription
end chat room message received
on active chat message received with eventDescription
end active chat message received
on addressed message received theMessage from theBuddy for theChat with eventDescription
end addressed message received
on received text invitation with eventDescription
end received text invitation
on received audio invitation theText from theBuddy for theChat with eventDescription
end received audio invitation
on received video invitation theText from theBuddy for theChat with eventDescription
end received video invitation
on received local screen sharing invitation from theBuddy for theChat with eventDescription
end received local screen sharing invitation
on buddy authorization requested with eventDescription
end buddy authorization requested
on addressed chat room message received with eventDescription
end addressed chat room message received
on received remote screen sharing invitation with eventDescription
end received remote screen sharing invitation
on login finished with eventDescription
end login finished
on logout finished with eventDescription
end logout finished
on buddy became available with eventDescription
end buddy became available
on buddy became unavailable with eventDescription
end buddy became unavailable
on received file transfer invitation theFileTransfer with eventDescription
end received file transfer invitation
on av chat started with eventDescription
end av chat started
on av chat ended with eventDescription
end av chat ended
on completed file transfer with eventDescription
end completed file transfer
end using terms from
Run Code Online (Sandbox Code Playgroud)
如果您从这个脚本开始并只实现您需要的方法(保持其余部分完好无损),那么您应该避免所有-1708错误.
在我看来,事件处理程序只有在Messagesmessage received中感觉像时才起作用。我遇到了同样的问题,但脚本略有不同。在另一个网站上找到另一个示例后,将其复制粘贴到新的 AppleScript 编辑器窗口中,并将其保存在消息复制到的 AppleScript 文件上,它开始工作。~/Library/Scripts/Messages
你的脚本好像没有问题。如果我用您的代码替换当前脚本并保存脚本,它会按预期工作,显示一个包含文本的对话框test。
只需将脚本设置为运行None并返回到您在消息设置中创建的脚本也可能就足够了。
| 归档时间: |
|
| 查看次数: |
4902 次 |
| 最近记录: |