2013-07-06 80 views
0

嗨,我是蘋果手稿的新手,但我試圖做一個獨立的應用程序,根據請求將打開Apple Mail使用是和無列表。我是新手,所以任何幫助將不勝感激。下面附上了我的代碼。如果yes_list然後... applescript

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 

不幸的是,即使我的命令被識別,我的操作仍然不起作用。任何幫助將不勝感激!謝謝!

回答

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 

如果其他測試,你必須首先實現從系統偏好設置朗讀項目,並按住聽音鍵(默認情況下逃生)來記錄答案。

+0

非常感謝你的魅力! – user2555399