【发布时间】:2014-06-08 06:52:13
【问题描述】:
我的AppleScript 正在工作,但如果我等待一段时间,即使使用“with timeout”语句,它也会超时。有人可以帮忙吗?并快速响应?它会在一定时间后到期。
谢谢!!!!!!
告诉应用程序“SpeechRecognitionServer”
超时 7200 秒
设置要监听的命令
{ “你是什么?”、“自我介绍”、“记笔记”、“启动 Safari”、 “结束 Safari”、“开始邮件”、“结束邮件”、“开始邮件”、“结束 消息”、“开始 FaceTime”、“结束 FaceTime”、“开始地图”、“结束地图”、 “播放音乐”、“启动 iTunes”、“结束 iTunes”、“播放”、“暂停”、“下一个 曲目”、“最后一首曲目”、“制作播放列表”、“开始 AppleScript”、“结束 AppleScript”、“开始日历”、“结束日历”}
提示“你好!
德尔福上线了! DELPHI 今天能为您提供哪些帮助?”
if commands is "What are you?" then
say "I am DELPHI, created from the brilliant mind of Nathan!"
end if
if commands is "Identify yourself" then
say "Macintosh DELPHI virtual assistant version 1.0"
end if
if commands is "Take note" then
say "Press 'Enter' key to input what you said and press 'esc' key to cancel."
tell application "System Events"
keystroke "s" using {command down, shift down}
end tell
end if
if commands is "Start Safari" then
tell application "Safari"
activate
end tell
end if
if commands is "End Safari" then
tell application "Safari"
quit
end tell
end if
if commands is "Start Mail" then
tell application "Mail"
activate
end tell
end if
if commands is "End Mail" then
tell application "Mail"
quit
end tell
end if
if commands is "Start Messages" then
tell application "Messages"
activate
end tell
end if
if commands is "End Messages" then
tell application "Messages"
quit
end tell
end if
if commands is "Start Maps" then
tell application "Maps"
activate
end tell
end if
if commands is "End Maps" then
tell application "Maps"
quit
end tell
end if
if commands is "Start iTunes" then
tell application "iTunes"
activate
end tell
end if
if commands is "End iTunes" then
tell application "iTunes"
activate
end tell
end if
if commands is "Play" then
tell application "iTunes"
play
end tell
end if
if commands is "Pause" then
tell application "iTunes"
pause
end tell
end if
if commands is "Next track" then
tell application "iTunes"
next track
end tell
end if
if commands is "Last track" then
tell application "iTunes"
previous track
end tell
end if
if commands is "Make a Playlist" then
tell application "iTunes"
make user playlist with properties {name:"User Selections"}
end tell
end if
if commands is "Start AppleScript" then
tell application "AppleScript Editor"
activate
end tell
end if
if commands is "End AppleScript" then
tell application "AppleScript Editor"
quit
end tell
end if
if commands is "Start Calendar" then
tell application "Calendar"
activate
end tell
end if
if commands is "End Calendar" then
tell application "Calendar"
activate
end tell
end if
set commands to listen for {"What are you?", "Identify yourself", "Take note", "Start Safari", "End Safari", "Start Mail", "End Mail", "Start Messages", "End Messages", "Start FaceTime", "End FaceTime", "Start Maps", "End Maps", "Start iTunes", "End iTunes", "Play", "Pause", "Next track", "Last track", "Make a Playlist", "Start AppleScript", "End AppleScript", "Start Calendar", "End Calendar"} with prompt "Is there anything else I can do?"
if commands is "What are you?" then
say "I am DELPHI, created from the brilliant mind of Nathan!"
end if
if commands is "Identify yourself" then
say "Macintosh DELPHI virtual assistant version 1.0"
end if
if commands is "Take note" then
say "Press 'Enter' key to input what you said and press 'esc' key to cancel."
tell application "System Events"
keystroke "s" using {command down, shift down}
end tell
end if
if commands is "Start Safari" then
tell application "Safari"
activate
end tell
end if
if commands is "End Safari" then
tell application "Safari"
quit
end tell
end if
if commands is "Start Mail" then
tell application "Mail"
activate
end tell
end if
if commands is "End Mail" then
tell application "Mail"
quit
end tell
end if
if commands is "Start Messages" then
tell application "Messages"
activate
end tell
end if
if commands is "End Messages" then
tell application "Messages"
quit
end tell
end if
if commands is "Start FaceTime" then
tell application "FaceTime"
activate
end tell
end if
if commands is "End FaceTime" then
tell application "FaceTime"
quit
end tell
end if
if commands is "Start Maps" then
tell application "Maps"
activate
end tell
end if
if commands is "End Maps" then
tell application "Maps"
quit
end tell
end if
if commands is "Start iTunes" then
tell application "iTunes"
activate
end tell
end if
if commands is "End iTunes" then
tell application "iTunes"
quit
end tell
end if
if commands is "Play" then
tell application "iTunes"
play
end tell
end if
if commands is "Pause" then
tell application "iTunes"
pause
end tell
end if
if commands is "Next track" then
tell application "iTunes"
next track
end tell
end if
if commands is "Last track" then
tell application "iTunes"
previous track
end tell
end if
if commands is "Make a Playlist" then
tell application "iTunes"
make user playlist with properties {name:"User Selections"}
end tell
end if
if commands is "Start AppleScript" then
tell application "AppleScript Editor"
activate
end tell
end if
if commands is "End AppleScript" then
tell application "AppleScript Editor"
quit
end tell
end if
if commands is "Start Calendar" then
tell application "Calendar"
activate
end tell
end if
if commands is "End Calendar" then
tell application "Calendar"
activate
end tell
end if
end timeout
end tell
【问题讨论】:
-
我清理了你的代码格式。
标签: applescript