Code: Select all
; This script plays sounds concurrently
#Requires AutoHotkey v1.1.33.11
sound := ["Tea Time.mp3", "ENG.mp3"]
Global playFile := A_ScriptDir "\play.ahk"
GroupAdd playing, % playFile " ahk_class AutoHotkey"
OnExit("stop")
Gui Font, s10
For fileNum in sound
Gui Add, Button, w210 gGo, % "Play " fileNum
Gui Add, Button, wp gF2, Play all
Gui Add, Button, wp gF3, Stop
Gui Show,, Sounds
Return
Go:
If RegExMatch(A_GuiControl, ".+?\K\d+$", fileNum)
play(sound[fileNum])
Return
F3::stop() ; F3 = Stop play
F2:: ; F2 = Start play
For each, filePath in sound {
play(filePath)
Sleep 2000
}
Return
play(filePath) { ; Play a sound file
If FileExist(filePath) {
If !FileExist(playFile)
FileAppend,
( % LTrim
#Requires AutoHotkey v1.1.33.11
#SingleInstance Off
#NoTrayIcon
SoundPlay % A_Args[1], % WAIT := True
ExitApp
), % playFile
Run % playFile " """ filePath """"
} Else MsgBox 48, Error, % "File not found.`n`n" filePath
}
stop(exitReason := "", exitCode := "") {
DetectHiddenWindows On
WinClose ahk_group playing ; Close all playing files (scripts)
}