Jump to content

Recommended Posts

Posted

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.

Posted

$Search = FileFindFirstFile(@WindowsDir&"\Media\*.wav")
While 1
    $FindNext = FileFindNextFile($Search)
    SoundPlay(@WindowsDir&"\Media\" & $FindNext, 1)
WEnd
FileClose($Search)

Posted (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 by JustinReno
Posted

$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)
  • Moderators
Posted

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.

Posted (edited)

As far as my computer tells me, nothing. It's probably different to you, you don't need to ridicule my statement.

Edited by JustinReno
  • Moderators
Posted

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.

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
×
×
  • Create New...