|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|||
|
DOS Batch - Play sounds at different time increments
I'm trying to create a batch file that will play a bunch of different sounds at different time increments.
Ideally this batch program will run from startup, and run for a few hours with sounds every so often, and then close. The user will not know that the batch program is running. This will be run in Windows XP. From what i have found so far, I need to use the command start /w /m sndrec32.exe /play /close %1 to run the sound recorder. It does not appear that this can be done using WMP. Can anyone give me any help as to how I can add time increments into the code and how to reference it to each sound file. Thanks, much appreciated. |
|
|||||
|
Hey there, arod,
Welcome to our forums. ![]() Programming batch files can be pretty neat when using for run-of-the-mill administrative tasks that would be either boring or too much to handle manually on a day-to-day basis. You pop up notepad, write your batch script that does what you were supposed to do, and then run it - voila. However, in your situation I sense that you are trying to code a slightly complex or rather complex application. I'm sure it can be done with batch and you should focus on how to invoke delays. A rather foolproof method do implement delays in a batch files is using ping time-outs. Sure, this sounds like insane and that it has nothing to do with it. However, the script must stop and ping the specified address (which should not exist) for the amount of time you specified without any output at all and then it moves on. You see, this is a rather simple and naive way to workaround a simple delay. The -n specifies the count of ping requests (1) while the -w explicitly states the number of wait time for each request (1000 ms = 1 second). NULL, as always, sets the output for the ping requests (technicall, NoWhereLand). ![]() Now to be on topic, I would advice writing your "application" in WSH. On the long-run you will be glad that you did. Sure, like I said, at first batch files look promising and quick solutions and we still should use them when we need to automate everyday administrative and/or boring tasks. But in your case you are planning to create a pretty neat utility that should run for hours or so I have understood. You have picked Sound Recorder and indeed that's what I would also too. It is also more light-weight and definitely faster/quicker/more efficient than WMP is/was/will be. There's no real need to involve WMP in this task. So, here's how I would do this in WSH. VB Code:
Hope it helps. You can use the same approach as presented above to reference to the audio files even with batch. But I still suggest moving over to WSH for the flexibility that it rather offers. Batch was all neat and cool in the 90s. Now it's all outdated and, to be honest, I haven't used it for my tasks since ages. If we think about it, batch is not even a programming language, it's just a scripting language that is based totally on DOS commands. Whereafter, WSH is a full-throttled and offers access/possilities to fully maintain and code lots of Microsoft-administration and -tedious tasks such as anything from sending mails (or even creating a mass-mailer) up to log parsing and whatnot. For more information and as a reference source on WSH - I would advice reading the article published by my very best friend - Robert "Nilpo" Dunham. Find his profile(s) over ASP Free and check out some of his WSH material/content; I'm linking both of his profiles because he's special and has two: Nilpo as a Staff Writer and Just Nilpo. He's written a lot on the subject (more than a few dozens of tutorials!). Cheers. If you have more questions or whatnot, please, don't hesitate to post. I might leave a PM to him if we both need assistance/help in order to accomplish your task. Because if we do that, then the guru will come and enlighten us. ![]()
__________________
“Greatness, combined with the hint of a 24-carat lifestyle, is within us striving to make it through, craving for attention, and in the end, recognition, leaving a record worthy of biography on forging success stories.” —ME Check out MadHyeNa's Website & Article Index. Visit Nilpo.com - Ask the Windows Guru!™I succeed, conquer, and achieve, therefore I am.™ |
|
|||
|
Thanks so much for you reply madhyena, that was a massive help.
I had actually done a bit more research since my post and found that VBScript was going to serve my purposes better as well! Unfortunately I have almost no experience in VB, but that's ok. The reason I'm doing this is actually for an April Fool's joke on a friend-I would like the computer to play random sounds at various times thoughout the day! I plan to put the script into the startup folder, which I am assuming will be executed on startup. The first issue I have is that I am seeing this friend on Sunday, and with April's Fool's day on Tuesday, I obviously don't want the code to execute on Monday when she starts up her computer. Ss there some way I can make the code so it only executes on 01/04/08, instead of everytime the computer starts up? Secondly, the time delays are in milliseconds I assume? Is there some way that instead of having a nominal time delay that I can actually get each sound to execute at a specific time throughout the day? ie. one sound at 9:00am, the next at 9:45 etc? That's all the questions I have for now. If anyone has any ideas to add to what I'm planning it would be much appreciated! Thanks |
|
|||
|
In regards to using a message box, I'm currently including the line for this between lines 4 and 5.
When I do this, the delay doesn't begin counting until I click 'Ok' on the message box. Is it possible to make it that the delay starts counting as soon as the message box comes up? Thanks |
![]() |
| Viewing: Dev Hardware Forums > SOFTWARE > Programming > DOS Batch - Play sounds at different time increments |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|