无法使应用程序进入类型应用程序

时间:2017-07-04 13:41:28

标签: shell applescript osascript

脚本错误:无法将应用程序转换为类型应用程序。 (-1700) 检测到错误的参数数据或执行强制操作时出现故障。 (第17行,第28号字符)。我认为这可能是我的对话框弹出或下面一行的脚本的问题。

using terms from application 'Messages'
  on message sent theMessage with eventDescription
    display dialog (eventDescription)
  end message sent

  on message received theText from theBuddy with eventDescription
  end message received

  on chat room message received theText with eventDescription from theBuddy for theChat
    set getname to name of theBuddy as text
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 
    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  end chat room message received

  on active chat message received theText with eventDescription from theBuddy for theChat
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 

    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  end active chat message received

  on addressed message received theText with eventDescription from theBuddy for theChat
    set getname to name of theBuddy as text
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 
    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  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 buddy authorization requested with eventDescription
  end buddy authorization requested

  on addressed chat room message received with eventDescription
  end addressed chat room message received

  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

1 个答案:

答案 0 :(得分:1)

我只是将'Messages'更改为"Messages"并允许我编译,也许这会对您有帮助。

更改第一行:

using terms from application 'Messages'

要:

using terms from application "Messages"

希望这有帮助!