Skip to main content
Inspiring
December 16, 2011
Answered

How to play a Warning Sound on Windows?

  • December 16, 2011
  • 4 replies
  • 1049 views

Customer wants me to have some audio feedback in case somethings goes wrong with script. (E.g.: User clicks on script although no document is open).

They do not like alerts.

On Mac it is easy:

app.doScript("beep",ScriptLanguage.APPLESCRIPT_LANGUAGE);

Is there an easy, reliable way to do it for our Windows friends?

Thanks,

Ralf

This topic has been closed for replies.
Correct answer John Hawkinson

Have you tried simply

  beep();

? I have had mixed results with it but I think it usually works.

4 replies

liedzeitAuthor
Inspiring
December 19, 2011

Thank you, guys.

Ralf

Marc Autret
Legend
December 17, 2011

John is correct: the  (global) function beep() should work in both Win and Mac through the JavaScript engine. For some reason it is not documented in the ESTK object viewer, but it appears in the following list:

alert( $.global.reflect.methods );

You can also check this:

alert( 'beep' in $.global ); // => true

alert( typeof beep ); // => function

What is fun is that the previous lines also play the beep, although the function is not explicitly invoked! [EDIT: probably because the alert() function itself runs a beep!]

Another fact is that beep() triggers a Windows sound event (Asterisk) which is defaultly associated to the "Windows Error.wav" file, but this depends on your "Sound" Settings (Control Panel > Sounds).

http://www.sevenforums.com/attachments/tutorials/194d1225616162-sounds-change-sound.jpg

Also note that in some Windows installation, sounds may be totally disabled, so that beep() is mute.

@+

Marc

Inspiring
December 17, 2011

beep is a little bit dull… on the mac you can also just use 'say' from 'standard additions'…

say "Mark you stupid Muppet" using "Bad News" volume 1

'play sound' is also fun for adding audio…

Sorry I don't know how I would humour myself if I were on a PC…

John Hawkinson
John HawkinsonCorrect answer
Inspiring
December 16, 2011

Have you tried simply

  beep();

? I have had mixed results with it but I think it usually works.