Triggering Music from mControl

Standard

The title of this post is more general than the actual task. Specifically, I implemented a new method to play a different song for each weekday the first time a motion sensor is triggered.

A while back I  played a song from iTunes whenever a specific event was detected in mControl (I’ve used two different methods to handle this). After I upgraded from version 2 to version 3 of mControl I held off on adding this capability back into the macros. The method for using iTunes worked fine but this time around I wanted to find something simpler to use that could be enhanced via scripting.

This time I used a free command-line utility called cmdmp3 that can play an MP3 file. In mControl I added a new item to a macro (Run Application), which executes a batch file that contains the necessary command-line parameters to play the songs. The batch file actually plays a different song for each weekday.

I’ve included the basic framework for the batch file. The code used to get the current day of the week and then run specific sections of the batch file was obtained from a forum post.

The batch file could use some refinement. For example, I had planned to place each song path in its own variable, but I had some problems getting the variables to work properly as parameters for cmdmp3. If I had worked that out then each section would simply have a song variable assigned to another variable that would serve as the parameter for cmdmp3.

Eventually I’d like to make the song selection randomized, which would considerably shorten the necessary code for the batch file by eliminating the test for the day of the week along with the related sections.

@echo off
for /f %%a in ('date /t') do set DAY=%%a
if %DAY%==Sun goto :sun
if %DAY%==Mon goto :mon
if %DAY%==Tue goto :tue
if %DAY%==Wed goto :wed
if %DAY%==Thu goto :thu
if %DAY%==Fri goto :fri
if %DAY%==Sat goto :sat

:sun
c:\tools\cmdmp3win.exe "filepath"
goto next

:mon
c:\tools\cmdmp3win.exe "filepath"
goto next

:tue
c:\tools\cmdmp3win.exe "filepath"
goto next

:wed
c:\tools\cmdmp3win.exe "filepath"
goto next

:thu
c:\tools\cmdmp3win.exe "filepath"
goto next

:fri
c:\tools\cmdmp3win.exe "filepath"
goto next

:sat
c:\tools\cmdmp3win.exe "filepath"
goto next

:next

Everything after “:next” can include whatever you may want to add after the song is played. If you don’t need to add anything then you can simply leave it as it is.

Updated 11/21/2011: I seem to have run into a familiar problem – executing external programs from within mControl. The batch file itself is sound but either mControl has a bug or the other program I’m using to execute external applications isn’t working properly. It may just be a configuration issue but I’ll need to spend some time on it before I can provide a proper solution for making this work from mControl.

Where Can I Find ImageX for Windows 7?

Standard

It seems that the imagex tool is only available as part of the Windows Automated Installation Kit (WAIK). For Windows 7 the kit is an ISO disc image available for download from Microsoft. The Website reports that the download size is 1 GB, though my download currently shows that the file is 1.7 GB.

While writing this post I’m in the process of downloading the disc image. At this point I don’t know exactly what I’ll need to do to get the file into an active Windows 7 installation, but I’m assuming I’ll be able to boot the Windows PE disc and then copy the imagex tool out.

My intention is to use this tool to backup an active Windows 7 system. The image will be stored on a drive attached to a Mac across the network.

It may be possible to find a site that offers only the imagex tool itself for download. However, I think downloading the file directly from Microsoft in its current packaging is probably the best method.

Update: The WAIK can be installed directly into a running system without having to boot into a Windows PE environment. However, imagex seemed to have an issue with creating an image on a network share. It’s likely that I was missing some steps or information. I ended up going the easy route and simply using the built-in Windows backup utility instead.