2014-06-29, 14:50
(2014-06-28, 09:05)pr0xZen Wrote: So I'm clear on this: Does this script only function on an AVR with NW connectivity? - also I'm not quite sure what you mean by , needs to be escaped everywhere with ` (autohotkey). Maybe I'm just slow today, but I want to make this work right.
Comma's are part of the ahk scripting language so you need a tilde before them so ahk will treat them as a regular character. The above will only work with a networked avr, below should toggle between two types of settings and display a notification in xbmc (note I havent tested it, just copy and pasted from above. Plus you'll need to change the file paths, ip address and port numbers):
Code:
#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
IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
{
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
FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.off
}
else
{
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
FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off
}