Code: Select all
SoundPlay, C:\Example-Sound_1.mp3
Sleep, 3000
SoundPlay, C:\Example-Sound_2.mp3
Code: Select all
SoundPlay, C:\Example-Sound_1.mp3
Sleep, 3000
SoundPlay, C:\Example-Sound_2.mp3
Code: Select all
#Requires AutoHotkey v1.1.33.11
s1 := "s1.wav"
s2 := "s2.wav"
playAudio(s1)
playAudio(s2)
playAudio(audioFile) {
psScript := "(New-Object Media.SoundPlayer """ audioFile """).PlaySync()"
Run % "powershell -NoProfile -Command & {" psScript "}",, Hide
}
try:just like via SoundPlay
Code: Select all
SoundPlay, C:\Example-Sound_1.mp3
Sleep, 3000
SoundPlay("C:\Example-Sound_2.mp3")
q::SoundPlayEnd() ; Ends all running SoundPlay(File)
SoundPlay(File) {
FileDelete, ~.ahk
FileAppend,#NoTrayIcon`nFileDelete`,~.ahk`nSoundPlay`,%File%`,1,~.ahk,UTF-8
Run, ~.ahk
} SoundPlayEnd() {
DetectHiddenWindows On
SetTitleMatchMode, 2
While, WinExist("~.ahk")
WinClose
}
Code: Select all
FileDelete, ~.ahk
FileAppend,#NoTrayIcon`nFileDelete`,~.ahk`nSoundPlay`,%File%`,1,~.ahk,UTF-8
Run, ~.ahk
Code: Select all
SoundPlayEnd() ; to delete possible ~.ahk
SoundPlay("C:\Example-Sound_1.mp3")
Sleep, 3000
SoundPlay("C:\Example-Sound_2.mp3")
q::SoundPlayEnd() ; Ends all running SoundPlay(File)
SoundPlay(File) {
While, FileExist("~.ahk")
Sleep, 10
FileAppend,#NoTrayIcon`nFileDelete`,~.ahk`nSoundPlay`,%File%`,1,~.ahk,UTF-8
Run, ~.ahk
} SoundPlayEnd() {
DetectHiddenWindows On
SetTitleMatchMode, 2
While, WinExist("~.ahk")
WinClose
FileDelete,~.ahk
}
Code: Select all
SoundPlay(File) {
While, FileExist("~.ahk")
Sleep, 10
FileAppend,#NoTrayIcon`nFileDelete`,~.ahk`nSoundPlay`,%File%`,1,~.ahk,UTF-8
ExitApp ; Run, ~.ahk <<<
}
Code: Select all
#NoTrayIcon
FileDelete,~.ahk
SoundPlay,C:\Example-Sound_1.mp3,1
Code: Select all
; SoundPlay.ahk
#NoTrayIcon
SoundPlay,% A_Args[1], 1
Code: Select all
; Main.ahk
SoundPlay(A_WorkingDir "\Example-Sound_1.mp3")
Sleep, 3000
SoundPlay(A_WorkingDir "\Example-Sound_2.mp3")
q::SoundPlayEnd() ; Ends all running SoundPlay.ahk
SoundPlay(File) { ; runs a new instance of SoundPlay.ahk
Run, "%A_WorkingDir%\SoundPlay.ahk" "%File%"
; and passes the path of the sound file
} SoundPlayEnd() {
DetectHiddenWindows On
SetTitleMatchMode, 2 ; closes the hidden script windows
While, WinExist("SoundPlay.ahk")
WinClose ; of all instances of SoundPlay.ahk
}
Code: Select all
#NoTrayIcon
SoundPlay,% A_Args[1], 1
Code: Select all
; Main.ahk
SoundPlay(A_WorkingDir "\Tea Time.mp3")
Sleep, 3000
SoundPlay(A_WorkingDir "\ENG.mp3")
q::SoundPlayEnd() ; Ends all running SoundPlay.ahk
SoundPlay(File) { ; runs a new instance of SoundPlay.ahk
Run, "%A_WorkingDir%\SoundPlay.ahk" "%File%"
; and passes the path of the sound file
} SoundPlayEnd() {
DetectHiddenWindows On
SetTitleMatchMode, 2 ; closes the hidden script windows
While, WinExist("SoundPlay.ahk")
WinClose ; of all instances of SoundPlay.ahk
}
Code: Select all
; This script plays sounds concurrently
#Requires AutoHotkey v1.1.33.11
Global playFile := A_ScriptDir "\play.ahk"
GroupAdd playing, % playFile " ahk_class AutoHotkey"
OnExit("stop")
F3::stop() ; F3 = Stop play
F2:: ; F2 = Start play
play("Tea Time.mp3")
play("ENG.mp3")
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)
}
No idea! Here with Unicode A_AhkVersion: 1.1.37.01 64bit I can even run nine .mp3 at the same time!Am I right?
But again, the first track stops after the time of Sleep. Where am I doing wrong?