[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Making my internal speaker beep

Matt Ramos

2/20/2006 6:16:00 PM

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-....


5 Answers

james_b

2/20/2006 6:22:00 PM

0

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


matthew.moss.coder

2/20/2006 6:22:00 PM

0

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.


William James

2/20/2006 10:57:00 PM

0


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-....

print "\a"

MenTaLguY

2/20/2006 11:07:00 PM

0

Quoting William James <w_a_x_man@yahoo.com>:

> print "\a"

mnemonic: "a" is for audiable

-mental


William James

2/21/2006 12:01:00 AM

0


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.