Interupting a loop - how?

My telephone answering (Ovolab) has a complicated system where the caller can also select to alert the person close to the mac. It happens with this:

on do_action given call:theCall
	tell application "Ovolab Phlink"
		tell theCall
			set tone sequence to ""
			// this is said to the caller
			speak "Wait a second. Alarming the vet. Do not hang up."
			repeat 3 times
				tell application "Finder"
					set volume 7
					// this from the mac speakers
					say "Important call to the vet. Pick up the phone."
					beep
				end tell
				
			end repeat
			// this to the caller
			speak "Please, hang up and call again after a moment."
			
		end tell
	end tell
end do_action

How should I do that this would alert the person sitting at the same computer? I mean a message on the screen without stopping the script?
Also, how should I make it possible to terminate - and shut up - the script by hitting a key or something.

All ideas welcome! Thanks in advance!

Hello.

I think you may interrupt the script by pressing cmd period. I have a solution for you that displays large types on the screen.

You can download quicksilver for free : from here


on do_action given call:theCall
	tell application "Ovolab Phlink"
		tell theCall
			set tone sequence to ""
			// this is said to the caller
			speak "Wait a second. Alarming the vet. Do not hang up."
			repeat 3 times
				tell application "Finder"
					set volume 7
					// this from the mac speakers
					say "Important call to the vet. Pick up the phone."
					tell application "Quicksilver" to show large type "Important call to the vet. Pick up the phone."
					beep
				end tell
				
			end repeat
			// this to the caller
			speak "Please, hang up and call again after a moment."
			
		end tell
	end tell
end do_action

Here’s a handler to post an alert on the screen without pausing a script. Notice the “ignoring” part which means don’t wait for a response.

set theText to "The text for the alert dialog!"

nonstoppingAlert(theText)
say "See, this runs even though the alert is still being displayed!"

on nonstoppingAlert(theText)
	ignoring application responses
		tell application "System Events"
			activate
			display alert "Pay Attention!" message theText buttons {"OK"} default button 1
		end tell
	end ignoring
end nonstoppingAlert

EDIT:
Changed the script to an all-applescript method

Thanks for the replies!

The command-period seems to work but the problem is to dig the script up when the Mac is running multious taskings …

This nonstoppingAlert is good, thanks! I tried it already and it works. For some reason it’s not working all the time :frowning: I’m studying it hard, sorry, I’m a newbie!

Thank you for the quick response. All ideas still welcome!

It stopped working for me too at one point. I had to open the “Activity Monitor” program and quit “System Events” to get it working. Then it worked again. I guess you should change “System Events” to “Finder” in the script. See if that prevents the problem. Maybe system events loses the dialog if it goes to the background. Since there’s no real way to make system events come to the front again (because it doesn’t have an interface) maybe that’s when it gets stuck.

I tried that, too. Changed System to Finder. It still do not work all the times.
I try to find out the reason.

If you’re still having problems make sure you quit the “systems events” process in “activity monitor”.

Note that if the script is not reliable then there is another way. We can tell the shell to run the applescript, and we can also tell the shell to not wait for a response…

on nonstoppingAlert(theText)
	set a to "tell application \"Finder\""
	set b to "activate"
	set c to "display alert \"Pay Attention!\" message \"" & theText & "\" buttons {\"OK\"} default button 1"
	set d to "end tell"
	
	do shell script "/usr/bin/osascript -e " & quoted form of a & " -e " & quoted form of b & " -e " & quoted form of c & " -e " & quoted form of d & " > /dev/null 2>&1 &"
end nonstoppingAlert

Hello.

I just wanted to add that the quicksilver solution, work all the time, and shows the text in large types all over the screen in front of all windows. It goes away nicely the moment you click somewhere on your screen, or hit a key.