' ------------------------------------------------------------------------------------ ' RecordSound.vbs ' Record a wav sound file with the same name as the current picture ' ------------------------------------------------------------------------------------ Option Explicit app.clearTrace dim alb, pic, file, k, fso, f, a const lRunParam = &h10001 Const ForWriting = 2 const sTemplateFile = "D:\workspace\AM\gui\help\images\template.wav" set alb = app.GetCurrentAlbum if not alb is nothing then set pic = alb.GetVisiblePicture( alb.nCurrentPicture ) if not pic is nothing then ' Get the real filename of the picture and replace the extension with "wav" file = alb.ExpandMacro( pic, "%RP" ) k = instrrev( file, "." ) file = left(file,k) & "wav" ' Copy the template file so soundrec will know the format to use Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists( sTemplateFile ) then Set a = fso.GetFile( sTemplateFile ) a.Copy file else ' No template, create an empty file so sndrec doesn't complain Set f = fso.OpenTextFile( file, ForWriting, True ) f.Close end if ' app.Trace file ' Launch the recorder app.Run "sndrec32 " & file, False, lRunParam msgbox "jlkjlkj" ' Set the PlayCommand so the new file will be played k = instr( file, " " ) if k <> 0 then pic.sPlayCmd = "media|" & file else pic.sPlayCmd = "wav|" & file end if end if end if