..by "subcommand" you mean the Ahkfile..
I meant to say subscript. mb

The only thing is it seems to hang if theres no pause before removing the sub command (working on a fix).
These are fun to play with, but I realized they have a flaw.
:arrow: There is some small amount of time required before the "subcommand" can play the audio file.
It looks like the audio has to be loaded (or buffered) into memory before any action can be taken on the underlying 'play file'.
I found this in the ahksc
ResultType Line::SoundPlay(char *aFilespec, bool aSleepUntilDone)
{
char *cp = omit_leading_whitespace(aFilespec);
if (*cp == '*')
return g_ErrorLevel->Assign(MessageBeep(ATOU(cp + 1)) ? ERRORLEVEL_NONE : ERRORLEVEL_ERROR);
// ATOU() returns 0xFFFFFFFF for -1, which is relied upon to support the -1 sound.
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_play.asp
// for some documentation mciSendString() and related.
char buf[MAX_PATH * 2]; // Allow room for filename and commands.
mciSendString("status " SOUNDPLAY_ALIAS " mode", buf, sizeof(buf), NULL);
if (*buf) // "playing" or "stopped" (so close it before trying to re-open with a new aFilespec).
mciSendString("close " SOUNDPLAY_ALIAS, NULL, 0, NULL);
snprintf(buf, sizeof(buf), "open "%s" alias " SOUNDPLAY_ALIAS, aFilespec);
if (mciSendString(buf, NULL, 0, NULL)) // Failure.
return g_ErrorLevel->Assign(ERRORLEVEL_ERROR); // Let ErrorLevel tell the story.
g_SoundWasPlayed = true; // For use by Script's destructor.
if (mciSendString("play " SOUNDPLAY_ALIAS, NULL, 0, NULL)) // Failure.
return g_ErrorLevel->Assign(ERRORLEVEL_ERROR); // Let ErrorLevel tell the story.
// Otherwise, the sound is now playing.
g_ErrorLevel->Assign(ERRORLEVEL_NONE);
if (!aSleepUntilDone)
return OK;
// Otherwise, caller wants us to wait until the file is done playing. To allow our app to remain
// responsive during this time, use a loop that checks our message queue:
// Older method: "mciSendString("play " SOUNDPLAY_ALIAS " wait", NULL, 0, NULL)"
for (;;)
{
mciSendString("status " SOUNDPLAY_ALIAS " mode", buf, sizeof(buf), NULL);
if (!*buf) // Probably can't happen given the state we're in.
break;
if (!strcmp(buf, "stopped")) // The sound is done playing.
{
mciSendString("close " SOUNDPLAY_ALIAS, NULL, 0, NULL);
break;
}
// Sleep a little longer than normal because I'm not sure how much overhead
// and CPU utilization the above incurs:
MsgSleep(20);
}
return OK;
}
Looks like this accesses C:\WINDOWS\system32\mciwave.dll
Not sure yet what messages are returned though.
As ref'd in the sc:
<!-- m -->
http://msdn.microsof...ibrary/ms712842<!-- m -->
<!-- m -->
http://msdn.microsof...ibrary/ms709492<!-- m -->
edit:
This function is great for playing audio!
<!-- m -->
http://www.autohotke...pic.php?t=20666<!-- m -->