The winsound
module in Python 3 provides an interface to interact with the sound playing machinery in Windows. The MessageBeep
function plays a built-in Windows sound. The syntax of the MessageBeep
function is as follows:
winsound.MessageBeep(type=MB_OK)
type
is a winsoud.MB_
value that specifies which system sound to play. The following table summarizes the sounds available:winsound Values |
Corresponding Control Panel Sound |
---|---|
MB_ICONASTERISK |
Asterisk |
MB_ICONEXCLAMATION |
Exclamation |
MB_ICONHAND |
Critical Stop |
MB_ICONQUESTION |
Question |
MB_OK |
System Default |
Note: If
-1
is passed, then a default beep is played.
MessageBeep
returns None
.The following code provides an example of how to use the MessageBeep
function:
import winsoundwinsound.MessageBeep(winsound.MB_ICONHAND)
In the example above, the Critical Stop built-in sound is played using the MessageBeep
function.
Free Resources