强制退出Applescript

时间:2014-05-16 13:51:31

标签: applescript

我正在制作一个文本游戏,但是当用户按下退出时,无法让它在中途结束脚本。我已经尝试退出,返回并且错误-128但它们都没有工作。

代码不在tell / end tell中,因为我不想使用某个应用程序,但是我已经尝试将它放在一个带有finder的内部,但是没有工作要么..

感谢任何帮助:)

set temp to display dialog "Welcome" buttons {"Play", "Quit"}
if temp = "Quit" then
error number -128
end if

set temp to display dialog "What is your name?" default answer "Joe" buttons {"Submit"}
set userName to text returned of temp
etc. etc.

2 个答案:

答案 0 :(得分:4)

另一种解决方案:定义取消按钮。

display dialog "Welcome" buttons {"Play", "Quit"} cancel button "Quit"
-- no need to check the button returned, the script quit automatically when user cancelled
set temp to display dialog "What is your name?" default answer "Joe" buttons {"Submit"}
set userName to text returned of temp
etc. etc.

答案 1 :(得分:2)

你应该得到按钮返回:

if button returned of temp = "Quit" then
   error number -128
end if
相关问题