我正在制作一份帮助学校的苹果。您键入要访问的主题,然后打开该文件夹(在应用程序内)。但是,有些科目有电子书,所以我希望有另一个对话框,询问你是否想要打开电子书或文件夹。不幸的是,display dialog
无法从另一个显示对话框中分支出来。
到目前为止,我发现的唯一方法是指导应用程序运行另一个脚本(在应用程序的" Scripts"文件夹中)。我试过了
tell application "Script Editor" to run script (path to me as sting) & "Contents:Resources:Scripts:Subject.scpt"`
但它没有用。对不起,如果我咆哮错误的树,看起来完全愚蠢。感谢
答案 0 :(得分:1)
据我了解您要尝试实现的目标,以下脚本可以正常运行。
set listOfSubjects to {"Math", "Biology", "History", "Languages"}
set subjectsWithEbook to {"Biology", "History"}
choose from list listOfSubjects with prompt "Select the subject"
set subject to item 1 of result
set openEbook to false
repeat with subjectItem in subjectsWithEbook
if subjectItem contains subject then
choose from list {"Open folder", "Open Ebook"} with prompt "What to open?"
set openType to item 1 of result
if openType contains "Open Ebook" then
set openEbook to true
end if
exit repeat
end if
end repeat
if openEbook then
--Open ebook
else
--Open folder
end if
答案 1 :(得分:0)
我猜您要输入主题名称?以下是使用对话框的示例。
set subjectFolderPath to (path to me as string) & "Contents:Resources:Subjects:"
set subjectsWithEbook to {"English", "Spanish"}
display dialog "What subject would you like to access?" default answer ""
set theSubject to text returned of the result
if theSubject is in subjectsWithEbook then
display dialog "Would you like to open the Folder or the Book?" buttons {"Folder", "Book"} default button 1
set toOpen to button returned of the result
if toOpen is "Book" then
-- tell app "Preview" to open ???
beep
else
tell application "Finder" to open folder (subjectFolderPath & theSubject & ":")
end if
else
tell application "Finder" to open folder (subjectFolderPath & theSubject & ":")
end if
您可能还希望获得允许的主题列表并对其进行错误检查。