Bạn sẽ nhận được Lỗi -1708 bất cứ khi nào bạn đã chọn AppleScript không xử lý sự kiện được chỉ định.
Ví dụ, nếu kịch bản của bạn chỉ thực hiện on message sent
, nhưng bạn thiết lập kịch bản này để chạy mỗi khi bạn nhận một tin nhắn, bạn sẽ nhận được Lỗi -1708. Điều này là do tập lệnh của bạn chỉ biết cách xử lý gửi đi, chứ không phải thư đến, do đó, Lỗi -1708.
Bây giờ đây là một cái gì đó thú vị ...
Nếu bạn cố gắng sử dụng kịch bản mặc định Mix Message Case.applescript
cho các sự kiện Message Received
, Message Received in Active Chat
, và Message Sent
. Việc đầu tiên và cuối cùng tốt, nhưng bạn sẽ nhận được một lỗi -1708 cho sự kiện trò chuyện hoạt động. Chúng tôi có thể suy ra rằng điều này có nghĩa là tập lệnh không xử lý sự kiện Message Received in Active Chat
. Và do đó, có vẻ như ngay cả Apple cũng không thể xử lý sự kiện này ngay bây giờ.
OS X Mavericks Cập nhật:
Bản cập nhật này sửa chữa các lỗi đề cập trước đây. Nếu bạn chọn tập lệnh mẫu của Apple Nói sự kiện.applescript, bạn sẽ nhận thấy rằng nó xử lý các tin nhắn được gửi đến phòng trò chuyện hoạt động hoàn hảo. Nếu bạn kiểm tra mã, bạn sẽ thấy rằng nó đang sử dụng phương thức on active chat message received
. Bây giờ chúng ta có thể sử dụng nó trong các kịch bản của mình. Vì tôi không còn cài đặt phiên bản cũ, tôi không thể kiểm tra xem phương thức này có hoạt động trong phiên bản trước không.
Đây là mã từ Sự kiện nói.applescript:
on active chat message received with eventDescription
say eventDescription
end active chat message received
Cũng lưu ý cách bạn không còn chỉ định từng tập lệnh chạy cho các sự kiện cụ thể. Thay vào đó, bạn chỉ định một trình xử lý tập lệnh đơn cho các sự kiện Tin nhắn. Điều này có nghĩa là bạn phải thực hiện tất cả các sự kiện để tránh bị các phương thức -1708. Chú ý trong các kịch bản mẫu, Apple thậm chí có nhận xét # The following are unused but need to be defined to avoid an error
. Đây là một mẫu có thể được sử dụng như là một điểm khởi đầu cho các kịch bản:
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
Nếu bạn bắt đầu với kịch bản này và thực hiện chỉ những phương pháp bạn cần (trong khi rời khỏi phần còn lại nguyên vẹn), sau đó bạn nên tránh tất cả -1708 lỗi.
bạn đã bao giờ tìm ra điều này chưa? –
Haha, cùng một vấn đề ở đây. AppleScript, một ngôn ngữ có khái niệm hiện đại như vậy nhưng với thông báo lỗi nhắc nhở bạn về những năm 1980! – Feuermurmel
Lỗi nói "Sự kiện chưa được xử lý" [http://developer.apple.com/legacy/library/#documentation/Carbon/Reference/Apple_Event_Manager/Reference/reference.html), nhưng tôi không thể tìm thấy sự kiện cho Tin nhắn đã nhận trong Trò chuyện hiện hoạt – drinchev