input without blocking

A

Alpha Chen

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wrote a little timer application and I would like it to play a
sound when the timer has counted down to 0.

You could always try RubyCocoa. From the main page (http://
rubycocoa.sourceforge.net/doc/):

The next script plays all the system sounds.

require 'osx/cocoa'
snd_files =`ls /System/Library/Sounds/*.aiff`.split
snd_files.each do |path|
snd = OSX::NSSound.alloc.
initWithContentsOfFile_byReference (path, true)
snd.play
sleep 0.5
end

Alpha Chen
0xCDE1AD58 on keyserver.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEKWnCTm5GrM3hrVgRAj3zAJ4tiRkOE4YgVoQQYP3f5opN7yjgmACgmpSK
dRXzk95XsgMd4kJvuoHq+WY=
=CMM9
-----END PGP SIGNATURE-----
 
C

Chris Alfeld

exec "osascript -e 'beep 1'"

Or, better yet, get ahold of osx/aeosa and use those bindings.
 
B

brian yahn

Chris said:
exec "osascript -e 'beep 1'"

Or, better yet, get ahold of osx/aeosa and use those bindings.

cin >> blocks. cin is basically the same thing as gets. I guess I will
just use a thread, but it seems kind of pointless to make the processor
have to schedule just for input.
 
E

Ernest Obusek

This is awesome! Thank you!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



You could always try RubyCocoa. From the main page (http://
rubycocoa.sourceforge.net/doc/):

The next script plays all the system sounds.

require 'osx/cocoa'
snd_files =`ls /System/Library/Sounds/*.aiff`.split
snd_files.each do |path|
snd = OSX::NSSound.alloc.
initWithContentsOfFile_byReference (path, true)
snd.play
sleep 0.5
end

Alpha Chen
0xCDE1AD58 on keyserver.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEKWnCTm5GrM3hrVgRAj3zAJ4tiRkOE4YgVoQQYP3f5opN7yjgmACgmpSK
dRXzk95XsgMd4kJvuoHq+WY=
=CMM9
-----END PGP SIGNATURE-----
 
L

Logan Capaldo

--Apple-Mail-10--57133659
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed


exec "osascript -e 'beep 1'"

I hope you never want to return after beeping


--Apple-Mail-10--57133659--
 
C

Chris Alfeld

It isn't so much that I never want to return as that I want to become
one with the osascript and exit after beeping =3D)

My bad, meant 'system' not 'exec'; too much tcl in my past.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,062
Members
47,669
Latest member
johnmaxwell

Latest Threads

Top