Forum: Ruby Making my internal speaker beep

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6de7ba135902e959c4c731f6afa0f40d?d=identicon&s=25 Matt Ramos (Guest)
on 2006-02-20 19:16
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
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-02-20 19:22
(Received via mailing list)
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"
  puts "\C-G"
  sleep(1)
  puts "\C-G"
  puts "\C-G"
end



--
James Britt

"You harmonize; then you customize."
  - Wilson Pickett
6de7ba135902e959c4c731f6afa0f40d?d=identicon&s=25 Matt Ramos (Guest)
on 2006-02-20 19:24
Thanks for the quick response.

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



Thanks again :)
81d609425e306219d54d793a0ad98bce?d=identicon&s=25 Matthew Moss (Guest)
on 2006-02-20 19:25
(Received via mailing list)
puts "\007"
2ee1a7960cc761a6e92efb5000c0f2c9?d=identicon&s=25 William James (Guest)
on 2006-02-21 00:00
(Received via mailing list)
Matt Ramos wrote:
>
> 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"
912c61d9da47754de7039f4271334a9f?d=identicon&s=25 unknown (Guest)
on 2006-02-21 00:09
(Received via mailing list)
Quoting William James <w_a_x_man@yahoo.com>:

> print "\a"

mnemonic: "a" is for audiable

-mental
2ee1a7960cc761a6e92efb5000c0f2c9?d=identicon&s=25 William James (Guest)
on 2006-02-21 01:04
(Received via mailing list)
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.
This topic is locked and can not be replied to.