gpt4 book ai didi

applescript - 尝试从OS X消息接收带有AppleScript的消息

转载 作者:行者123 更新时间:2023-12-04 04:12:43 25 4
gpt4 key购买 nike

嘿,我正在运行以下脚本:

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

但是,每次收到消息时,每次在消息中都会收到以下错误:
Event: Message Received in Active Chat
File: registerToReceiveMessages.applescript
Error: Error -1708

我在互联网上的任何地方都找不到该错误。它似乎适用于除事件聊天之外的所有聊天。有任何想法吗?

另外,我正在尝试为“收到的已寻址消息”添加事件,但是每次我编译applescript时都将其替换为“收到的远程屏幕共享邀请”

最佳答案

每当您选择了不处理指定事件的AppleScript时,您将得到错误-1708

例如,如果您的脚本仅实现了on message sent,但是您将此脚本设置为在每次收到消息时都运行,则将收到错误-1708。这是因为您的脚本只知道如何处理传出消息,而不是传入消息,因此错误-1708。

现在这很有趣...

如果您尝试对事件Mix Message Case.applescriptMessage ReceivedMessage Received in Active Chat使用默认脚本Message Sent。第一个和最后一个工作正常,但是您将在事件聊天事件中收到-1708错误。我们可以推断出这意味着脚本未处理事件Message Received in Active Chat。因此,似乎苹果公司现在都无法处理此事件。

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

另请注意,您不再指定要针对特定​​事件运行的单个脚本。而是为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

如果从此脚本开始并仅实现所需的方法(而其余方法保持不变),则应避免所有-1708错误。

关于applescript - 尝试从OS X消息接收带有AppleScript的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12377572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com