Jump to content
Sign in to follow this  
JustinReno

File Find and play

Recommended Posts

JustinReno

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.

Share this post


Link to post
Share on other sites
_Kurt

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

Share this post


Link to post
Share on other sites
Nahuel

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

Share this post


Link to post
Share on other sites
JustinReno

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

Share this post


Link to post
Share on other sites
AdmiralAlkex

$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)

Share this post


Link to post
Share on other sites
JustinReno

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.

Share this post


Link to post
Share on other sites
AdmiralAlkex

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

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
JustinReno

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

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
JustinReno

Guess I'll have to run out then.

Share this post


Link to post
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
Sign in to follow this  

×