How to ring the system bell with Ruby (Win32)
August 16, 2008
There a couple ways to accomplish this. My application required the first option because the second wouldn’t work from within Eclipse.
require "win32/sound"
include Win32
Sound.play(SystemAsterisk", Sound::ALIAS) # play system asterisk sound
Sound.beep(600,200) # play a beep 600 hertz for 200 milliseconds
or
irb(main):001:0> puts "\a"
=> nil
irb(main):002:0>
The Ruby on Windows blog has some additional info about Adding Sound to Your Ruby Apps.
(Side note: I’ve posted this because it was almost impossible to find by googling. See for yourself what happens when you search for “ruby ring a bell”- you’ll get about 200,000 false positives.)













Posted in



Recent Comments