我一直在尝试为自动化脚本创建一个 JavaScript,以通过 Yosemite 10.10.2 上的 Messages 应用程序发送 iMessage(最终目标是编写一个解决方案以允许后台任务到 iMessage 故障状态等)。
脚本在脚本编辑器中执行没有错误,但是没有消息发送,Messages.app 中没有任何显示或发生。虽然我的服务和下面的好友被混淆了,但我的具有真实值的脚本检索了正确的服务和好友(通过对服务和好友名称执行 messages.displayAlert() 进行验证)。我从脚本中得到的唯一输出是 service.send() 的“未定义”,我认为这是正确的,因为该方法具有 void 返回类型)。下面的这个脚本是我一直没有成功尝试开始工作的脚本:
messages = Application('Messages');
service = messages.services["E:foo@bar.com"];
buddy = service.buddies["+61nnnnnnnnn"]
service.send({
send: "Hello World",
to: buddy
});
Run Code Online (Sandbox Code Playgroud)
等效的 AppleScript 脚本(如下)成功运行:
tell application "Messages"
send "Hello World" to buddy "+61nnnnnnnnn" of service "E:foo@bar.com"
end tell
Run Code Online (Sandbox Code Playgroud)