Jump to content

MsgBoxSound Udf


ResNullius
 Share

Recommended Posts

After helping out on this thread http://www.autoitscript.com/forum/index.ph...=50966&st=0

I decided to make a few changes and now you can call any of the standard message boxes that AutoIt can create and assign your choice of wav sounds to be played. If you omit the parameter $sSound then the deafult sound is used. To have a silent MsgBox, then pass $sSound as "".

MsgBox(32, "Hey...", "What's that?")
_MsgBoxSound(32 + 4, "", "Aren't you going to answer the phone", 0,@WindowsDir & "\MEDIA\ringout.wav")
_MsgBoxSound(32, "Well...", "Who was it?",0, "") ; no sound
MsgBox(32,"Huh...","What do you meany you can't hear me?")

Func _MsgBoxSound($iFlag, $sTitle, $sText, $nTime = 0, $sSound = "default")
  Local $aEventSounds[3][5] = [[0, 16, 32, 48, 64], [".DEFAULT", "SystemHand", "SystemQuestion", "SystemExclamation", "SystemAsterisk"], ["", "", "", ""]]
  If StringLower($sSound) = "default" Or Not FileExists($sSound) AND $sSound <> "" Then
    Return MsgBox($iFlag, $sTitle, $sText, $nTime)
  Else
    For $iFlagIndex = 64 To 0 Step - 16
      If BitAND($iFlag, $iFlagIndex) = $iFlagIndex Then
        Local $iEventIndex = $iFlagIndex / 16
        $aEventSounds[2][$iEventIndex] = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[1][$iEventIndex] & "\.Current", "")
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[1][$iEventIndex] & "\.Current", "", "REG_EXPAND_SZ", $sSound)
        Local $nMsgBox = MsgBox($iFlag, $sTitle, $sText, $nTime)
        RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\" & $aEventSounds[1][$iEventIndex] & "\.Current", "", "REG_EXPAND_SZ", $aEventSounds[2][$iEventIndex])
        Return $nMsgBox
      EndIf
    Next
  EndIf
EndFunc   ;==>_MsgBoxSound

edit: thanks also (as usual) to SmOke_N whose code in the earlier mentioned thread formed the basis of the udf's core :)

Edited by ResNullius
Link to comment
Share on other sites

Nice function, although whilst the second msgbox is open, and another msgbox from a different app opens up with same flags, it will also have phone sound.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Nice function, although whilst the second msgbox is open, and another msgbox from a different app opens up with same flags, it will also have phone sound.

True, but I'm not smart enough :) to do whatever custom dll calls you'd need to make to do it any other way, if it's possible.

Of course you can always program you own GUI msgbox and play a sound on its appearance, but I just thought this would be simple for some folk to use...

Link to comment
Share on other sites

@ResNullius

Nice you can also create a customized gui and use SoundPlay with it, instead of creating a MsgBox and modifiying the registry :)

I know, see my last post 2 posts back:

Of course you can always program you own GUI msgbox and play a sound on its appearance, but I just thought this would be simple for some folk to use...

Link to comment
Share on other sites

  • 1 year later...

:mellow: very cheeky what you're doing !

very nice. thanks a lot.

another way to manipulate sounds would be to temporarily rename the files themselves. but i have no idea which method would be faster or more secure.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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...