AppleScript exit if no action I would like my script to stop automatically unless I press a button.

display dialog "Continue" with icon caution buttons {"Exit", "Continue"} default button 1 giving up after 2
if the button returned of the result is "Exit" then
    return
end if


Obviously with the script bellow, I have my default answer selected, I have a time out but at the end of the time out "Exit" is not automatically pressed and the script continue.

Is the only way to do that is to swap the script around like this :

if the button returned of the result is "Continue" then
    -- add the "continue script"
end if
Return
Negate your 'fail' structure to make it an 'if not pass' instead.

display dialog "Continue" with icon caution buttons {"Exit", "Continue"} default button 1 giving up after 5
if the button returned of the result is not "Continue" then     
    return "exit"
else
    return "continue"
end if