在Applescript上强制退出

在Applescript上强制退出,applescript,Applescript,我正在制作一个文本游戏,但当用户按下退出键时,无法让它在中途结束脚本。我尝试过退出、返回和出错-128,但都不起作用 代码不在tell/end-tell中,因为我不想使用应用程序,但我尝试使用finder将其放在一个应用程序中,这也不起作用 感谢您的帮助:) 您应该返回按钮: if button returned of temp = "Quit" then error number -128 end if 您应该返回按钮: if button returned of temp = "Qu

我正在制作一个文本游戏,但当用户按下退出键时,无法让它在中途结束脚本。我尝试过退出、返回和出错-128,但都不起作用

代码不在tell/end-tell中,因为我不想使用应用程序,但我尝试使用finder将其放在一个应用程序中,这也不起作用

感谢您的帮助:)


您应该返回按钮:

if button returned of temp = "Quit" then
   error number -128
end if

您应该返回按钮:

if button returned of temp = "Quit" then
   error number -128
end if

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

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.

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

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.

只是试了一下,没用:(谢谢,无论如何,虽然很聪明,我甚至试了那个,写错了。)谢谢尼科尔:)只是试了一下,没用。(谢谢,无论如何,虽然很聪明,我甚至试了那个,写错了。)谢谢尼科尔:)