随后有两个对话框,在Applescript中有很多选择

时间:2013-11-26 15:09:41

标签: applescript

我创建了一个脚本,允许我为我的工作创建文件夹和组织文件。

但我希望有一个第一个对话框询问我是否要创建一个" web项目"或者"图形项目"。然后,根据我的选择,第二个对话框给了我几个选择。

说明:

如果我选择一个" Web项目"在第一个对话框中。这将打开第二个对话框,其中包含几个新选项。

请你帮帮我吗?

这是我创建的第一个对话框:(它完美无缺)

set theName to (choose from list {¬
    "Create Web Project", ¬
    "Create Graphic Project"})

if theName is false then

    display dialog "Cancelled." buttons {"Exit"} default button {"Exit"} with icon note

else

    if first item of theName = "Create Web Project" then
        set userResponse to (choose from list {¬
            "Create Responsive Website Project", ¬
            "Create Desktop Website Project", ¬
            "Create Mobile Website Project", ¬
            "Create Tablet Website Project"})

        tell application "Finder"
            set resPath to (path to me as text) & "Contents:Resources:Scripts:Web:" & userResponse & ".scpt"
            set the_script to load script alias resPath
        end tell

        run script the_script


    else if first item of theName = "Create Graphic Project" then
        set userResponse to (choose from list {¬
            "Create Basic Design Project", ¬
            "Create Print Design Project", ¬
            "Create ADS Banner Design Project"})

        tell application "Finder"
            set resPath to (path to me as text) & "Contents:Resources:Scripts:Graphic:" & userResponse & ".scpt"
            set the_script to load script alias resPath
        end tell

        run script the_script

    end if  

end if

已编辑:我已编辑了代码启发的代码。它有效,但我没有好警报框!

1 个答案:

答案 0 :(得分:1)

尝试:

set theName to (choose from list {¬
    "Create Web Project", ¬
    "Create Graphic Project"})

if first item of theName = "Create Web Project" then
    set userResponse to choose from list {"A", "B"}
else if first item of theName = "Create Graphic Project" then
    set userResponse to choose from list {"C", "D"}
end if