Stereo Tool
https://forums.stereotool.com/

Autohotkey: easy JSON query to toggle Bypass?
https://forums.stereotool.com/viewtopic.php?t=33623
Page 1 of 1

Author:  MrKlorox [ Sat Jul 15, 2023 11:50 pm ]
Post subject:  Autohotkey: easy JSON query to toggle Bypass?

Hi. So I've been messing with AutoHotkey and trying to set up a couple of hotkeys for restarting soundcards and toggling bypass. I have the soundcard restarting function working. I have the ability to turn on or turn off the bypass by forcing a value (0 or nonzero).

However, I don't know how to do a Bypass toggle that doesn't need to query the current state and make a decision on what to respond with. I was hoping just sending the "237" signal would work to toggle whatever the state is; like 10439 restarts soundcards without having to force a value.

Right Ctrl+Numpad Divide send a restart signal to the soundcards with this:
Code:
>^NumpadDiv::
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "http://127.0.0.1:8080/json-1/list`%7B`%2210439`%22`%7B`%7D`%7D", false)
try whr.Send()
this is the actual URL it sends http://127.0.0.1:8080/json-1/list%7B"10439"%7B%7D%7D which works for its button.

However, this command for Right Ctrl+Numpad Multiply does not do anything unless I tell it a value to force.
Code:
>^NumpadMult::
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "http://127.0.0.1:8080/json-1/list`%7B`%22237`%22`%7B`%7D`%7D", false)
try whr.Send()
http://127.0.0.1:8080/json-1/list%7B"237"%7B%7D%7D is the URL.

However, this URL DOES turn off the bypass
http://127.0.0.1:8080/json-1/list%7B%22 ... 0%22%7D%7D

And this URL enables it (same with the value 1 or -1. Sadly -1 doesn't toggle it either)
http://127.0.0.1:8080/json-1/list%7B%22 ... 1%22%7D%7D

Is anybody familiar enough with JSON and AutoHotkey to where they can help me make a script that can check its state, then send an opposing value? Should I contact Hans and ask for an easy toggle function to call that doesn't require a specific value to work?

Thanks!

edit2: Optimially I think it would be handy to be able to force a new_value of "-1" and have Stereo Tool toggle the bypass from its current state (before re-setting the value appropriately internally or whatever makes it work the next time it's sent).


edit1: fixed up some grammar and added some links

Author:  MrKlorox [ Tue Aug 08, 2023 10:01 pm ]
Post subject:  Re: Autohotkey: easy JSON query to toggle Bypass?

Thanks to @TheDaChicken for helping me figure out this Bypass hotkey. Press CTRL+/ on the numpad to toggle the bypass.
Code:
^NumpadMult::  ; 237 = Bypass TOGGLE
CurrentValue := GetResponse() ;; Get current value
NewValue := (InStr(CurrentValue """value"": ""1""", false) != 0) 
byp0 := ComObjCreate("WinHttp.WinHttpRequest.5.1")
byp0.Open("GET", "http://127.0.0.1:8080/json-1/list%7B%22237%22%3A%7B%22forced%22%3A%221%22%2C%20%22new_value%22%3A%20%22"
   . NewValue . "%22%7D%7D", true)
try byp0.Send()
Return

Page 1 of 1 All times are UTC+02:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/