Jump to content

File Find and play


Recommended Posts

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

$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 :P

$Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav")
While 1
    $FindNext = FileFindNextFile($Search)
    If @error Then ExitLoop
   SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1)
WEnd
FileClose($Search)
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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

  • Moderators

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

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