Making my internal speaker beep

Hello. I'm trying to execute a beep on my computer with ruby as an
alert, but I can't seem to get it to work.

I've looked online and I have this.

require "Win32API"
def beep
  o = Win32API.new("kernel32","Beep",%w(i i) , 'v')
  o.call(2000,50)
end

It seems to be calling the API exactly how I need, but it won't execute
the beep. Any tips/ideas?

Thanks,
Matt

···

--
Posted via http://www.ruby-forum.com/.

Matt Ramos wrote:

Hello. I'm trying to execute a beep on my computer with ruby as an alert, but I can't seem to get it to work.

This works for me on Win2k

def beep
  puts "\C-G"
  sleep(1)
  puts "\C-G"
end

···

--
James Britt

"You harmonize; then you customize."
  - Wilson Pickett

puts "\007"

···

On 2/20/06, Matt Ramos <matt.ramos@gmail.com> wrote:

Hello. I'm trying to execute a beep on my computer with ruby as an
alert, but I can't seem to get it to work.

Matt Ramos wrote:

Hello. I'm trying to execute a beep on my computer with ruby as an
alert, but I can't seem to get it to work.

I've looked online and I have this.

require "Win32API"
def beep
  o = Win32API.new("kernel32","Beep",%w(i i) , 'v')
  o.call(2000,50)
end

It seems to be calling the API exactly how I need, but it won't execute
the beep. Any tips/ideas?

Thanks,
Matt

--
Posted via http://www.ruby-forum.com/\.

print "\a"

Thanks for the quick response.

What is the C-G? Is there a way to change the frequency?

Thanks again :slight_smile:

···

--
Posted via http://www.ruby-forum.com/.

Quoting William James <w_a_x_man@yahoo.com>:

print "\a"

mnemonic: "a" is for audiable

-mental

mental@rydia.net wrote:

Quoting William James <w_a_x_man@yahoo.com>:

> print "\a"

mnemonic: "a" is for audiable

-mental

Or perhaps for "alert".
This also works in awk.