Ignoring alerts on OS X

In running a loop, I’m continuously performing an action which returns an alert each time. The result is an inordinate amount of alert messages which I have to click OK through.

I’m looking for a way to automate or ignore the alert messages.

I thought I’d found what I was looking for in Akua Sweets, with the “automate alerts after” command. However there’s no OS X version of the script addition.

Any suggestions?


Try using ‘ignoring application responses’. This means your code keeps executing when dialogs are produced. You can then use System Events to imitate the Return key being pressed. An example:

tell application "Finder"
	repeat with x from 1 to 5
		-- Use ignoring.
		ignoring application responses

			-- The code to generate the message goes here.
			-- e.g.
			display alert "Alert window " & x
		end ignoring

			-- The System Events block imitates the return button being pressed.
			tell application "System Events"
				delay 0.25 -- A delay to make sure the window has appeared.
				key code 36 -- Return key
			end tell		
	end repeat
end tell

Also, does your script need to generate the alerts in the first place? Can you be more specific about what you are doing?

Best wishes

John M


Just a detail.
Why are you using key code 36 which may be specific to one keyboard when the keystroke return command is guaranteed operational worldwide ?

Yvan KOENIG (from FRANCE jeudi 21 septembre 2006 21:43:42)

Good point Yvan. I didn’t know that. The dictionary for keystroke doesn’t suggest that things like ‘return’ or ‘tab’ would be applicable.

John M