PlaySound() Function
- Last UpdatedJun 07, 2022
- 1 minute read
Plays a sound from a wave file or a Windows default sound.
Syntax
Playsound (soundname, flag)
Parameters
soundname
The name of the sound or wave file. A literal string value, message tagname, or string expression. If the sound is defined as a name, it must be defined in the Win.ini file under the [Sounds] section, for example MC="c:\test.wav"
flag
Specifies how the sound is played. A literal integer value, integer tagname, or integer expression with the following meanings:
0 - Play sound one time synchronously (script execution waits until sound has finished playing).
1 - Play sound one time asynchronously (script execution does not wait until sound has finished playing).
9 - Play sound continuously (until the PlaySound() function is called again).
Example(s)
This script plays the sound of the file c:\welcome.wav one time and holds script execution until it has finished playing.
PlaySound("c:\welcome.wav",0);
This script plays the sound Alert continuously. In the win.ini file [Sounds] section you need to associate the sound name Alert with a sound file, such as:
Alert=c:\alert.wav.
PlaySound("Alert",9);