2014-05-28, 09:16
can anyone please provide a step by step instruction for beginners (windows 8) how to switch between two audio outputs?
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
;check or existing avr* files
IfNotExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
IfNotExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
;no avr.* files found, assuming avr off
FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off
;loop to ping for avr connectivity and adjust windows/xbmc settings to suit.
Loop
{
Ping("192.168.1.201")
If ErrorLevel
{
;avr no ping
;Msgbox, avr not pinging.
IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
{
;Msgbox, avr.off exists
Sleep, 1000
}
else
{
;Msgbox, no avr.off exists
Msgbox, About to reset GPU due to AVR`, Save everything and press OK
Run, schtasks /run /TN "win-audio-reset",,Hide
IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.on
FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off
Sleep, 1000
Run, C:\emulation\emulators\killapp.bat,,Hide
WinWait, XBMC ahk_class XBMC
Sleep, 10000
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":1}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":false}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"TV\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
}
}
else
{
;avr ping
;Msgbox, avr is pinging.
IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
{
;Msgbox, avr.on exists
Sleep, 1000
}
else
{
;Msgbox, no avr.on exists
Msgbox, About to reset GPU due to AVR`, Save everything and press OK
Run, schtasks /run /TN "win-audio-reset",,Hide
IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.off
FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.on
Sleep, 1000
Run, C:\emulation\emulators\killapp.bat,,Hide
WinWait, XBMC ahk_class XBMC
Sleep, 10000
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":8}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":true}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthroughdevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"AVR\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
}
}
}
;Ping Function
Ping(IPADDRESS)
{
Runwait,%comspec% /c ping -n 1 %IPADDRESS%>C:\Users\xbmc\AppData\Local\Temp\ping.log,,hide
fileread , PingLog, C:\Users\xbmc\AppData\Local\Temp\ping.log
ifinstring , PingLog, Destination host unreachable
{
ErrorLevel = 1
}
else
{
ErrorLevel = 0
}
;Msgbox, echo %ErrorLevel%
}
(2014-06-28, 17:39)Ed76 Wrote: i switch between hdmi audio (tv) and my stereo speakers. for me all is working fine