Change Beep to Flash

I want to be able to change the system beep (alert) to a screen flash on Panther. It is easy to do manually by setting the alert volume in the Sound preference panel to 0 and then enabling the flash in the Universal Access panel. But can it be done with a script? I tried all the obvious things and nothing worked. Thanks.

I’ve been trying GUI Scripting to make this work, but I get an error on the line of code that is commented out…

tell application "System Preferences" to activate
tell application "System Events"
	tell process "System Preferences"
		delay 2
		click menu item "Universal Access" of menu "View" of menu bar 1
		delay 2
		tell window "Universal Access"
			tell tab group 1
				click radio button "Hearing"
				delay 2
				
				--click checkbox "Flash the screen when an alert sound occurs" of tab group 1 of window "Universal Access"

			end tell
		end tell
	end tell
end tell

Change the commented line to simply

click checkbox “Flash the screen when an alert sound occurs”

and it works. I’m not sure, but since you are already inside a “tell” statement to the first tab group, the rest seems redundant/unnecessary.

But I still have two problems:

One, I’m bad with UI scripting and I’m not exactly sure how to set the alert volume to zero.

Two, this scheme is slow and requires System Preferences to be running, which makes it impractical for what I’m trying to do, although it may still help somewhat.

P.S. You must have a lousy computer. :stuck_out_tongue: I completely removed those “delay” commands on mine.

Well, here’s my next attempt:


tell application "Finder" to set process_list to every process
if process_list does not contain "System Preferences" then
	tell application "System Preferences" to activate
	delay 2
end if
tell application "System Events"
	tell process "System Preferences"
		click menu item "Sound" of menu "View" of menu bar 1
		tell window "Sound"
			tell tab group 1
				delay 2
				click radio button "Sound Effects"
				set (value of slider 1) to 0
			end tell
		end tell
		--delay 1
		click menu item "Universal Access" of menu "View" of menu bar 1
		--delay 1
		tell window "Universal Access"
			tell tab group 1
				delay 2
				click radio button "Hearing"
				
				if value of checkbox "Flash the screen when an alert sound occurs" is equal to 0 then
					click checkbox "Flash the screen when an alert sound occurs"
				end if
				
			end tell
		end tell
	end tell
end tell

Thanks for getting me started.

You got it NoBody. – A lousy computer – greggo laughs heheheee – it’s a lowly ole dually 450MHz – but I love it anyway ;¬)

PreFabs UI Browser is a life saver for GUI scripting…
http://prefab.com/uibrowser/index.html

Yes I agree, but the System Volume and Alert Volume are separate things and I know no way of scripting the Alert Volume other than GUI scripting. Maybe someone else can chime in here with another solution

Wow - I have a single 1 GHz G4, which wouldn’t seem that much faster from the specs.

Anyway, I totally agree with everything you said. Your method does work, and I was not insulting it. Plus, I was starting to doubt that there was any other way to do it anyway. I’m just thinking that for my purposes, if I can’t do it near-instantaneously, it’s really not worth doing at all.

I’m writing a companion to Ambrosia’s WireTap that allows you to control WireTap and iTunes from one panel. However, sometimes when I am recording with WireTap, I accidentally cause my system to beep, which ruins the whole recording. My idea was to change the beep to a flash when you hit record and change it back when you hit stop. But if it takes 10 seconds to start recording, it is not worth it. I think I’ll just leave my system on flash with a zero alert volume permanently, since I do a lot of recording. I’ll save my script in case someone asks me how they can do the same, but I don’t think it can be efficiently incorporated into my program.

Hi,

One workaround might be to swap the alert sound files. Say your alert sound file is System.aiff. Got to System > Library > where the sound is and duplicate System.aiff. Rename it to maybe MySystem.aiff and duplicate it again to another container. Place one in you user library sounds folder and somehow modify the duplicate so that it doesn’t make any sound. Then with applescript, try switching the files and check if it works. I don’t know if this would work yet. Just an idea.

editted: I forgot to say that you need to select your MySystem.aiff in system preferences.

gl,