SoundPlay

Plays a sound, video, or other supported file type.

SoundPlay, Filename [, wait]

 

Parameters

Filename

The name of the file to be played, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

To produce standard system sounds, specify an asterisk followed by a number as shown below (requires v1.0.28). Note: the wait parameter has no effect in this mode.
*-1: Simple beep. If the sound card is not available, the sound is generated using the speaker.
*16: Hand (stop/error)
*32: Question
*48: Exclamation
*64: Asterisk (info)

wait

If omitted, the script's current thread will continue running while the file is playing. If it's 1 or the word WAIT, the current thread will wait until the file is finished playing. Even while waiting, new threads can be launched via hotkey, custom menu item, or timer.

 

ErrorLevel

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

 

Remarks

All Windows OSes should be able to play .wav files. However, other files (.mp3, .avi, etc.) might not be playable if the right codecs or features aren't installed on the OS.

If a file is playing and the current script plays a second file, the first file will be stopped so that the second one can play. On some systems, certain file types might stop playing even when an entirely separate script plays a new file.

To stop a file that is currently playing, use SoundPlay on a nonexistent filename as in this example: SoundPlay, Nonexistent.avi

If the script is terminated, any currently-playing file that it started will stop.

 

Related

SoundBeep, SoundGet, SoundSet, SoundGetWaveVolume, SoundSetWaveVolume, MsgBox, Threads

 

Example

SoundPlay, %SystemRoot%\Media\ding.wav