you can control a repeat loop with the gave up parameter of display dialog, for example
repeat 10 times
set {button returned:bRet, gave up:gaveUp} to display dialog "Continue" buttons {"No", "Yes"} default button 2 giving up after 2
if bRet is "No" then exit repeat
delay 5
end repeat
if gaveUp then
display dialog "timed out"
else if bRet is "No" then
display dialog "Aborted"
end if
If you create a service that create a file with a given name, or an Apple Script that do the same, when a specific key is hit. (script installed via some utility on a hotkey).
Then you could check for the existence of that file in the repeat loop-
Script one goes like this and is installed on some hotkey. Which maybe the other script should do for you if feasable ( I really don’t know.)
set pauseFile to (path to desktop) & "Mypause.txt" as text
do shell script "touch " & quoted form of POSIX path of pauseFile
The main script with the loop contains something like this:
set pauseFile to (path to desktop) & "Mypause.txt" as text
repeat
try
pauseFile as alias ” generates err condition if pauseFile doesn't exist
try
display dialog "Continue?"
do shell script "rm " & quoted form of pauseFile
on error
do shell script "rm " & quoted form of pauseFile
end try
end try
” rest of your repeat loop goes here. You get straight here if no pausefile.
There are also some initiating to be done, to ensure the state of the script when starting up, like
removing any existent previous pause file (If your script died before removing it.