0

嗨,我是苹果脚本的新手,但我正在尝试制作一个独立的应用程序,根据请求将使用是和否列表打开 Apple Mail。我是新手,所以任何帮助将不胜感激。我在下面附上了我的代码。

set Unread_Count to unread count of inbox
if Unread_Count is 0 then
    say "Sir, it appears you have no new email's"
else if Unread_Count is 1 then
    say "You have 1 new email"
else
    say "You have " & (get Unread_Count) & " unread emails"
end if
end tell
tell application "SpeechRecognitionServer"
set yes_list to {"yes", "yes open mail", "yes open mail server", "yes please"}
set no_list to {"That's all", "no"}

set answer to listen for yes_list & no_list with prompt "Would you like me to open your mail server? Or will that be all."
-- you have to hold the Listening key (by default ⎋) to record a reply
if answer is no_list then
    delay 0.2
    say "Very well sir."
end if

if answer is yes_list then
    tell application "Mail"
        reopen
        activate
end tell
end if
end tell 

不幸的是,即使我的命令被识别,我的操作也不起作用。任何帮助将不胜感激!谢谢!

4

1 回答 1

0

使用contains关键字:

tell application "SpeechRecognitionServer"
    set l1 to {"yes", "maybe"}
    set l2 to {"no"}
    set answer to listen for l1 & l2 with prompt "prompt"
    l1 contains answer
end tell

如果其他人对此进行测试,您必须先从系统偏好设置中启用可朗读项目,然后按住监听键(默认为转义)以记录答案。

于 2013-07-06T17:06:45.923 回答