JustinReno Posted November 15, 2007 Share 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. Link to comment Share on other sites More sharing options...
_Kurt Posted November 15, 2007 Share 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.. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 15, 2007 Share 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 Link to comment Share on other sites More sharing options...
Nahuel Posted November 15, 2007 Share Posted November 15, 2007 $Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav") While 1 $FindNext = FileFindNextFile($Search) SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1) WEnd FileClose($Search) Link to comment Share on other sites More sharing options...
JustinReno Posted November 15, 2007 Author Share 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 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 15, 2007 Share 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 Link to comment Share on other sites More sharing options...
JustinReno Posted November 15, 2007 Author Share 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. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 15, 2007 Share 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 15, 2007 Moderators Share 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. Link to comment Share on other sites More sharing options...
JustinReno Posted November 15, 2007 Author Share 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 15, 2007 Moderators Share 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. Link to comment Share on other sites More sharing options...
JustinReno Posted November 15, 2007 Author Share Posted November 15, 2007 Guess I'll have to run out then. Link to comment Share on other sites More sharing options...
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