Jump to content

MsgBox() - Without The Ding.


Recommended Posts

Anyone know how to make a message box without the ding noise? I know I will likely have to make my own GUI based msgbox but I'm hopeing for a easier answer.

Thanks!

And yes I have read the help file entry and searched and can't find it...

AutoIt changed my life.

Link to comment
Share on other sites

  • Moderators

Turn the volume down? / Create your own?

The only value I'm aware of to do this is 32 for "question" icon.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Developers

the soundtype used depends on these :

decimal flag Icon-related Result hexadecimal flag

0 (No icon) 0x0

16 Stop-sign icon 0x10

32 Question-mark icon 0x20

48 Exclamation-point icon 0x30

for me the 32 doesn't give a sound ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Windows will make the message ding event. If you go in the registry, disable the sound event, then re-enable it, you will have no ding.

This sounds great however a bit out of my league, any advice to help me learn how to do this? An example would be great!

AutoIt changed my life.

Link to comment
Share on other sites

  • Moderators

Wouldn't this require a reboot? (Then you'd have to change it back to their default if they didn't want that ... again needing a reboot).

This is what I'm understanding ya'll are saying "would" work:

_myMsgBox(0, "Some Title", "Some Text")

Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)
    Local $sDefault = RegRead("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "")
    If $sDefault <> ".NONE" Then
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", ".NONE")
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", ".DEFAULT")
        Return $nMsgBox
    EndIf
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Just incase there is a sound setup that is not known as ".default", another words was saved as a favorite without the exact windows defaults, wouldn't it be better to just rewrite the read????

RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", $sDefault)

???

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Just incase there is a sound setup that is not known as ".default", another words was saved as a favorite without the exact windows defaults, wouldn't it be better to just rewrite the read????

RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", $sDefault)

???

8)

errrr... that's why I made the $sDefault... but I forgot to put it in there ... nice catch :)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

So would the corrected code then be?

_myMsgBox(0, "Some Title", "Some Text")

Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)
    Local $sDefault = RegRead("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "")
    If $sDefault <> ".NONE" Then
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", ".NONE")
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", $sDEFAULT)
        Return $nMsgBox
    EndIf
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
EndFunc

It still dings at me!

Help! I really want/need this and it seems so close.

AutoIt changed my life.

Link to comment
Share on other sites

  • Moderators

So would the corrected code then be?

_myMsgBox(0, "Some Title", "Some Text")

Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)
    Local $sDefault = RegRead("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "")
    If $sDefault <> ".NONE" Then
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", ".NONE")
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_USERS\.DEFAULT\AppEvents\Schemes", "", "REG_SZ", $sDEFAULT)
        Return $nMsgBox
    EndIf
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
EndFunc

It still dings at me!

Help! I really want/need this and it seems so close.

As I stated before... it's going to at least require a re-boot once it is changed I'm sure... the above code was just to prove that it wasn't as easy as the others had portrayed it to be with their suggestions.

My suggestion to you, is to look up MsgBox examples in the Examples forum, and see if there is a custom "GUI" message box that might suit your needs, because without yanking the speaker from inside the pc, rebooting all the time, or using the 32 code (question) you're going to get the beep.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This works for me on Win XP

MsgBox(0,"","I make noise")
_myMsgBox(0, "", "I'm quiet")
MsgBox(0,"","Now I make noise again")

Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)
    Local $sDefault = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "")
    If $sDefault <> ".NONE" Then
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "", "REG_SZ", "")
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "", "REG_SZ", $sDEFAULT)
        Return $nMsgBox
    EndIf
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
EndFunc

:)

Link to comment
Share on other sites

Thanks that works for me sorta, the first time I ran it the first msgbox made a noise the second and third didn't every time I ran it afterwards none of them make noise. Now if I make a script that is just

Msgbox(0,"","")

It makes no noise. I am also running XP anyone have any idea if the part that resets the sound is correct?

Thank you very much for entertaining my requests!

*edit*

Also it seems that other system issues that use that sound are not able to now heh

Edited by Skizmata

AutoIt changed my life.

Link to comment
Share on other sites

Thanks that works for me sorta, the first time I ran it the first msgbox made a noise the second and third didn't every time I ran it afterwards none of them make noise. Now if I make a script that is just

Msgbox(0,"","")

It makes no noise. I am also running XP anyone have any idea if the part that resets the sound is correct?

Thank you very much for entertaining my requests!

*edit*

Also it seems that other system issues that use that sound are not able to now heh

First, go into your Control Panel, into "Sounds, Speech, and Audio Devices" then "Sounds and Audio Devices" if you're in category view, or directly into "Sounds and Audio Devices" if you're in Classic view.

Go to the "Sounds Tab", and under "Program Events" highlight "Default Beep". Then select a wav in the dropdown below that, I suspect it must currently say ".None" My setting is for "Windows XP Ding.wav". Click "apply and that should restore the sound for that event. You can test by using the"play" arrow next to the wav file name.

Now, run this modified version, to see what's happening:

MsgBox(0,"","I make noise")
_myMsgBox(0, "", "I'm quiet")
MsgBox(0,"","Now I make noise again")
$sDefault = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "")
MsgBox(0,"Your default sound","is now: " &  $sDefault)

Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)
    Local $sDefault = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "")
    MsgBox(0,"Your default sound", $sDefault)
    If $sDefault <> "" Then
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "", "REG_SZ", "")
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current", "", "REG_SZ", $sDEFAULT)
        Return $nMsgBox
    EndIf
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
EndFunc

It should fix the problem, in which case you can remove the extraneous msg boxes showing the wav names.

I had left If $sDefault <> ".NONE" Then , and I should have changed it to If $sDefault <> "" Then as in the above.

Link to comment
Share on other sites

@ResNullius Thank you for all your help. After much fiddling around with it I think I have it worked out. Your version seems to work well.

Thanks to all thread contributors!!!

Now, as indicated earlier by JdeB, the sound type varies depending on the MsgBox value.

So the code I last posted only works for the standard type MsgBox(0,"","").

I'm whipping up some code that will actually iterate thru the list of all default assigned sounds to turn them off, run the MsgBox then turn them back on. Stay tuned....

Link to comment
Share on other sites

Ok, so here's the code to account for silent msgboxes of all the types AutoIt can make.

The demo cycles through them all to show.

And if somebody's just the least bit clever, they could figure out how to modify the function to assign custom sounds to the message boxes...

MsgBox(0,"","I make noise")
_myMsgBox(0, "", "I'm quiet")
_myMsgBox(16,"","I SAID I'M QUIET!")
_myMsgBox(32,"","What's that? You can't hear me")
_myMsgBox(48,"","Don't make a sound")
_myMsgBox(64,"","For your information, I didn't make a sound")
MsgBox(0,"","Whew, I make noise again")
MsgBox(16,"","HOW'S THAT!")
MsgBox(32,"","Am I making too much noise")
MsgBox(48,"","Nice to have my voice back")
MsgBox(64,"","For your information, I'm talking to you")


Func _myMsgBox($iFlag, $sTitle, $sText, $nTime = 0)

    Dim $aEventSounds[2][5]=[[".DEFAULT","SystemAsterisk","SystemExclamation","SystemHand","SystemQuestion"],["","","",""]]
    For $i = 0 to 4
    $aEventSounds[1][$i] = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[0][$i]  & "\.Current","")
    RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[0][$i] & "\.Current","","REG_SZ","")
    Next
    Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
    For $i = 0 to 4
     RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[0][$i] & "\.Current","","REG_EXPAND_SZ",$aEventSounds[1][$i])
  Next

EndFunc
Link to comment
Share on other sites

Maybe EnvUpdate() might help? It should help you if it won't work without reboot/logoff.

EnvUpdate() doesn't work... had tried it early on.

For an updated version of my code above, see http://www.autoitscript.com/forum/index.ph...c=51171&hl=

Allows you to set your own sounds for the standard msgbox calls, or no sound at all.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...