winsound.MessageBeep

3

3c273

Hello,
I was trying to use the MessageBeep fuction to play different system sounds,
but using the syntax in the docs, all I can get is the default sound.. While
I finally got my sounds to play using PlaySound, I am curious as to what I
was doing wrong with MessageBeep. (Win2000 & XP)

From the docs

MessageBeep( [type=MB_OK])

....The type argument specifies which sound to play; possible values are -1,
MB_ICONASTERISK, MB_ICONEXCLAMATION, MB_ICONHAND, MB_ICONQUESTION, and
MB_OK, all described below

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.(This works)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'MB_OK' is not defined

(OK I'm kind of new to this so maybe it needs quotes:)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required

So what do I need to do to play the other sounds listed in the docs (using
MessageBeep). Thanks.

Louis
 
L

Larry Bates

3c273 said:
Hello,
I was trying to use the MessageBeep fuction to play different system sounds,
but using the syntax in the docs, all I can get is the default sound.. While
I finally got my sounds to play using PlaySound, I am curious as to what I
was doing wrong with MessageBeep. (Win2000 & XP)

From the docs

MessageBeep( [type=MB_OK])

...The type argument specifies which sound to play; possible values are -1,
MB_ICONASTERISK, MB_ICONEXCLAMATION, MB_ICONHAND, MB_ICONQUESTION, and
MB_OK, all described below

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.(This works)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'MB_OK' is not defined

(OK I'm kind of new to this so maybe it needs quotes:)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required

So what do I need to do to play the other sounds listed in the docs (using
MessageBeep). Thanks.

Louis
You need to call winsound.MessageBeep(winsound.MB_OK)

(e.g. MB_OK isn't automatically bound to anything).

I tried all of the different sounds and they are different
on my machine with the default sounds turned on.

-Larry Bates
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top