JustinReno Posted November 15, 2007 Posted November 15, 2007 I was trying to figure out a way to find all the .wav files in my Windows Media directory (C:\WINDOWS\Media) and play them. I tried to edit this code from the help file and this is what I got. Does it work on your computer, it doesn't do anything on mine. $Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav") While 1 $FindNext = FileFindNextFile($Search) SoundPlay($FindNext, 1) WEnd FileClose($Search) Thanks.
_Kurt Posted November 15, 2007 Posted November 15, 2007 Why don't you check if there are any files in that directory, a simple ShellExecute should do.. ShellExecute(@WindowsDir&"\Media\") Kurt Awaiting Diablo III..
AdmiralAlkex Posted November 15, 2007 Posted November 15, 2007 I couldn't hear any sound but that infinite loop completely took over my processor, you should fix that first .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Nahuel Posted November 15, 2007 Posted November 15, 2007 $Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav") While 1 $FindNext = FileFindNextFile($Search) SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1) WEnd FileClose($Search)
JustinReno Posted November 15, 2007 Author Posted November 15, 2007 (edited) Thanks Nahuel, I'll see if that works. _Kurt: Usually with computers XP and above there is over 20 music sounds in there. Edit: Spelling, and thanks Nahuel, it works great! Edited November 15, 2007 by JustinReno
AdmiralAlkex Posted November 15, 2007 Posted November 15, 2007 $Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav") While 1 $FindNext = FileFindNextFile($Search) SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1) WEnd FileClose($Search)I just had to do this, I dont like infinite loops $Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav") While 1 $FindNext = FileFindNextFile($Search) If @error Then ExitLoop SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1) WEnd FileClose($Search) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
JustinReno Posted November 15, 2007 Author Posted November 15, 2007 The @Error line doesn't do much to stop it from an infinite loop unless there is an error. Its always going to be a loop.
AdmiralAlkex Posted November 15, 2007 Posted November 15, 2007 it will make the script stop when all files are played, so the only way for it to be infinite would be if you had an infinite amount of wavs in your media directory.... not likely to happen!! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Moderators SmOke_N Posted November 15, 2007 Moderators Posted November 15, 2007 The @Error line doesn't do much to stop it from an infinite loop unless there is an error. Its always going to be a loop.That's a rediculous statement... what do you think makes it throw an error? 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.
JustinReno Posted November 15, 2007 Author Posted November 15, 2007 (edited) As far as my computer tells me, nothing. It's probably different to you, you don't need to ridicule my statement. Edited November 15, 2007 by JustinReno
Moderators SmOke_N Posted November 15, 2007 Moderators Posted November 15, 2007 As far as my computer tells me, nothing. It's probably different to you, you don't need to ridicule my statement.You ridiculed his "correct" way to handle FileFindNextFile() ... can't take the heat, stay out of the kitchen! 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now