Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Microsoft

Play Random Sounds for E-Mail Notifications? 156

An anonymous reader asks: "I, like many of my fellow Outlook-using geek friends, like to set funny sounds to be played when a new message arrives ('Leeroy Jenkins' is the one I have set now). However, we have always wanted to be able to have random sounds be played when a new message arrives, rather than the same sound over and over. I've searched high and low, and I was hoping Slashdot could suggest/write a program that can randomly play sound files from a specified folder when a new message arrives. Any ideas?"
This discussion has been archived. No new comments can be posted.

Play Random Sounds for E-Mail Notifications?

Comments Filter:
  • by biglig2 ( 89374 ) on Tuesday July 19, 2005 @07:20PM (#13108668) Homepage Journal
    Use a seperate new e-mail notification program (that plays random sounds) in parallel to outlook.

    Or write a script that occasionally copies a random WAV to notify.wav (which is what outlook plays).

    BTW, the place to start looking for outlook info is the excellent slipstick.com
  • Perl... (Score:4, Informative)

    by RedPhoenix ( 124662 ) on Tuesday July 19, 2005 @07:46PM (#13108907)
    #!/usr/bin/perl
    $SOUNDDIR="/usr/share/sounds";
    $ DESTFILE="/tmp/sound.wav";
    opendir(DIR,$SOUNDDIR) || die "Can't open $SOUNDDIR: $!\n";
    $count=0;
    while(defined($file = readdir(DIR))) {
    if($file =~ /\.wav$/) {
    $files[$count]=$file;
    $count++;
    }
    }

    $arraysize=@files;
    while(1) {
    $rnd=int(rand($arraysize));
    $filename=$files[$rnd];
    `cp $SOUNDDIR/$filename $DESTFILE`;
    sleep 10;
    }

    Mangle appropriately (source dir, sleep time, dest file, file-type).

    Have fun.

    Red.
  • by croddy ( 659025 ) on Tuesday July 19, 2005 @08:02PM (#13109075)
    #!/bin/sh
    # updates the sound list

    path=$1

    find $path -name "*.[Oo][Oo][Gg]" -print > soundlist.txt
    find $path -name "*.[Mm][Pp][3]" -print >> soundlist.txt
    find $path -name "*.[Ww][Aa][Vv]" -print >> soundlist.txt
    find $path -name "*.[Ff][Ll][Aa][Cc]" -print >> soundlist.txt
    find $path -name "*.[Aa][Ii][Ff][Ff]" -print >> soundlist.txt

    #!/bin/sh
    # play random file from filelist

    filelist=$1

    len=`wc -l $filelist`
    n=`expr $RANDOM % $len`
    play `sed -n ${n}p $filelist`
  • by LordEd ( 840443 ) on Tuesday July 19, 2005 @09:41PM (#13109753)
    1. Write a simple application/script that plays a random sound file
    - Read directory and store files in a list/array
    - Use a random function to pick a wav file
    - Load and play the selected audio file

    2. Disable e-mail sound notifications (Tools->Options->Email options->Advanced email options->uncheck 'play a sound'

    3. Set up a rule for incoming email: (Tools->Rules wizard->New.
    Start from a blank rule. Check messages when they arrive (next).
    (Next) and confirm to apply to all rules.
    Check 'start application'. Click the underlined 'application'. Choose your custom app (open).
    (next)(next).
    Name the rule 'sound script'
    (finish)(ok).

    To prevent your script from playing sounds for every email received, put a delay counter on it to prevent multiple instances of the same application, or some form of lock preventing concurrent running.
  • by dasunt ( 249686 ) on Tuesday July 19, 2005 @09:46PM (#13109780)

    Not necessarily so.

    Imagine different pools of sound files. For example, one pool could be Futurama quotes. The other could be excerpts from Monty Python.

    Why you get new mail, it grabs a 'random' Futurama wav. When you have a new IM message, it grabs a 'random' Monty Python wav.

    As long as you have two brain cells to rub together, you can figure out that 'Bite my shiny metal ass' is new mail, while 'Ni!' is a new IM message.

  • Here is the code (Score:3, Informative)

    by FriedTurkey ( 761642 ) * on Wednesday July 20, 2005 @01:05AM (#13110841)
    Step 1 - Lower your macro security.

    Step 2 - Close Outlook and restart Outlook.

    Step 3 - Open up the Visual Basic editor.

    Step 4 - Add this in the code session of "ThisOutLookSession".

    Step 5 - Reformat the thing. I spent more time trying get it through the Slashdot filters than writing it.

    Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Function GetAllFilesInDir(ByVal strDirPath As String) As Variant ' Loop through the directory specified in strDirPath and save each ' file name in an array, then return that array to the calling ' procedure. ' Return False if strDirPath is not a valid directory. Dim strTempName As String Dim varFiles() As Variant Dim lngFileCount As Long On Error GoTo GetAllFiles_Err ' Make sure that strDirPath ends with a "\" character. If Right$(strDirPath, 1) "\" Then strDirPath = strDirPath & "\" End If ' Make sure strDirPath is a directory. If GetAttr(strDirPath) = vbDirectory Then strTempName = Dir(strDirPath, vbDirectory) Do Until Len(strTempName) = 0 ' Exclude ".", "..". If (strTempName ".") And (strTempName "..") Then ' Make sure we do not have a sub-directory name. If (GetAttr(strDirPath & strTempName) _ And vbDirectory) vbDirectory Then ' Increase the size of the array ' to accommodate the found filename ' and add the filename to the array. ReDim Preserve varFiles(lngFileCount) varFiles(lngFileCount) = strTempName lngFileCount = lngFileCount + 1 End If End If ' Use the Dir function to find the next filename. strTempName = Dir() Loop ' Return the array of found files. GetAllFilesInDir = varFiles End If GetAllFiles_End: Exit Function GetAllFiles_Err: GetAllFilesInDir = False Resume GetAllFiles_End End Function Private Sub Application_NewMail() Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 Dim varFileArray As Variant Dim lngI As Long Dim strDirName As String Const NO_FILES_IN_DIR As Long = 9 Const INVALID_DIR As Long = 13 On Error GoTo Test_Err strDirName = "C:\windows\media" varFileArray = GetAllFilesInDir(strDirName) For lngI = 0 To UBound(varFileArray) Debug.Print varFileArray(lngI) Next lngI lngI = Math.Round(Math.Rnd() * UBound(varFileArray)) WAVFile = "C:\windows\media\" & varFileArray(lngI) Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) Test_Err: Select Case Err.Number Case NO_FILES_IN_DIR MsgBox "The directory named '" & strDirName _ & "' contains no files." Case INVALID_DIR MsgBox "'" & strDirName & "' is not a valid directory." Case 0 Case Else MsgBox "Error #" & Err.Number & " - " & Err.Description End Select End Sub

    Step 6 - Ignore all replies to this post. They are all the same Microsoft bashing crap you've already read 1000 times on /.

    Step 7 - If you think this is some kind of virus learn to code and then you can check it yourself.

    Step 8 - Fix the API call. It is too slow.
  • by Oculus Habent ( 562837 ) * <oculus.habent@gma i l . c om> on Wednesday July 20, 2005 @01:16PM (#13114856) Journal
    Make a folder of the sounds you want.

    Copy one of them and name it "sound.wav" or somesuch.

    Make a Scheduled Task that runs every minute.

    When "sound.wav"'s Last Accessed time is within the minute, have it randomly select a new sound and overwrite "sound.wav".

Kleeneness is next to Godelness.

Working...