我一直在尝试构建一个脚本,通过显示对话框为您提供3种不同操作的选项,但是当我测试它们时,只有第一个选项有效。是否有解决办法,因为这是我的计划的中心点。任何帮助表示赞赏,并提前致谢!
set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"}
if the button returned of myQuery is "choice 1" then do script
if the button returned of myQuery is "choice 2" then do script
if the button returned of myQuery is "choice 3" then do script
在这种情况下,只选择一个脚本,另外两个失败。
答案 0 :(得分:0)
你走在正确的轨道上。这应该适合你
set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"}
if button returned of myQuery is "choice 1" then
say "you selected choice one" --replace this line with what ever you want
end if
if button returned of myQuery is "choice 2" then
say "you selected choice two" --replace this line with what ever you want
end if
if button returned of myQuery is "choice 3" then
say "you selected choice three" --replace this line with what ever you want
end if
答案 1 :(得分:0)
您的代码中存在大量冗余,并且三个单独的if
子句效率不高。
set {button returned:myQuery} to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"}
if myQuery is "choice 1" then
say "choice one"
else if myQuery is "choice 2" then
say "choice two"
else
say "choice three"
end if