vMix Forums
»
General
»
General Discussion
»
Http Request inside of vMix Script
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
Is it possible to call a http request as part of a vMix script?
I have one script that uses:
Dim client = WebRequest.create("http://192.168.200.192:8888/press/bank/13/11") Dim response = client.GetResponse()
This syntax does not work as part of another script though. Only standalone.
Any ideas?
Thank you!
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,223 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: obcocav
This syntax does not work as part of another script though. Only standalone.
What do you mean ?
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
Dim client = WebRequest.create("http://192.168.200.192:8888/press/bank/13/11") Dim response = client.GetResponse()
As the only thing in a standalone vmix script works.
If I try those lines as part of other functions in a new script it does not. For instance:
Funtion=SetTitlePreset&Value=0&Input=33 Sleep 5000
Dim client = WebRequest.create("http://192.168.200.192:8888/press/bank/13/11") Dim response = client.GetResponse()
That new script does not work.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,223 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: obcocav Dim client = WebRequest.create("http://192.168.200.192:8888/press/bank/13/11") Dim response = client.GetResponse()
As the only thing in a standalone vmix script works.
If I try those lines as part of other functions in a new script it does not. For instance:
Funtion=SetTitlePreset&Value=0&Input=33 Sleep 5000
Dim client = WebRequest.create("http://192.168.200.192:8888/press/bank/13/11") Dim response = client.GetResponse()
That new script does not work. Not a good idea to mix and match protocols https://forums.vmix.com/...ng-for-Dummies#post70833btw where did you get the SetTitlePreset function from ? Code:API.Function("SetText",Input:="Title 43- Circling Green.gtzip",SelectedName:= "Description.Text",Value:= "Hallo")
dim client as WebRequest= WebRequest.Create("http://127.0.0.1:8088/api/?Function=SetText&Input=Title 43- Circling Green.gtzip&SelectedName=Headline.Text&Value=other Text")
dim response As WebResponse = client.GetResponse()
response.Close
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
@doggy.
I used it from the Shortcut reference list. Works well.
As far as what I'm trying to accomplish. Maybe I wasn't clear. Sorry. I am trying to press a Companion button externally from inside of a vMix Script. So I need to use vMix functions then as part of that script call to a http address of an external program.
Thanks, Kevin
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,223 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: obcocav @doggy.
I used it from the Shortcut reference list. Works well.
As far as what I'm trying to accomplish. Maybe I wasn't clear. Sorry. I am trying to press a Companion button externally from inside of a vMix Script. So I need to use vMix functions then as part of that script call to a http address of an external program.
Thanks, Kevin Code is a working example of a vmix function AND a Httprequest within the same script. adapt to your needs I do not find the SetTitlePreset function/shortcut in vMix
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
Got it! Thank you! As to the SelectTitlePreset...Here you go. Screen Shot 2021-09-27 at 6.42.24 PM.png (461kb) downloaded 0 time(s).
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
@doggy.
So I got that working fine. Next issue. Can I have more than one request inside of each script? Im an amateur at this more advanced stuff but was getting a "client already exists" error in the script. I changed the name to add a number and it saved ok without errors but only the first request runs. What am I doing wrong?
Heres what I have:
API.Function("SelectTitlePreset",Input:="MESSAGE TO MONITOR", Value:= 3) Sleep (500) dim client as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/20/23") dim response As WebResponse = client.GetResponse() response.Close Sleep (100) dim client2 as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/13/5") dim response2 As WebResponse = client2.GetResponse() response.Close Sleep (500) API.Function("StartCountdown",Input:="MESSAGE TO MONITOR") Sleep (310000) dim client3 as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/13/2") dim response3 As WebResponse = client3.GetResponse() response.Close API.Function("SelectTitlePreset",Input:="MESSAGE TO MONITOR", Value:= 0) Sleep (500)
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 1/25/2019(UTC) Posts: 303 Thanks: 17 times Was thanked: 79 time(s) in 60 post(s)
|
if you want to send several commandos in a row, you only have to define the variables client and response once. in your code you have renamed the variable response to response2, but you close the previous connection response. Code:dim response as system.net.webresponse
dim client as system.net.webrequest
client = WebRequest.Create("http://localhost:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=Some Text")
response = client.GetResponse()
response.Close
sleep (1000)
client = WebRequest.Create("http://localhost:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=other text")
response = client.GetResponse()
response.Close
sleep (1000)
client = WebRequest.Create("http://localhost:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=213245546")
response = client.GetResponse()
response.Close
sleep (1000)
client = WebRequest.Create("http://localhost:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=end")
response = client.GetResponse()
response.Close
|
1 user thanked Peter1000 for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,223 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: obcocav
As to the SelectTitlePreset...Here you go.
Yup which is NOT the same as SetTitlePreset ;-)
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/18/2020(UTC) Posts: 18 Location: MS Was thanked: 1 time(s) in 1 post(s)
|
My bad! That was a mistype from the beginning. BTW the script I posted did work as listed after a restart of vmix. Strange. Thanks for your help!!
API.Function("SelectTitlePreset",Input:="MESSAGE TO MONITOR", Value:= 3) Sleep (500) dim client as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/20/23") dim response As WebResponse = client.GetResponse() response.Close Sleep (100) dim client2 as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/13/5") dim response2 As WebResponse = client2.GetResponse() response.Close Sleep (500) API.Function("StartCountdown",Input:="MESSAGE TO MONITOR") Sleep (310000) dim client3 as WebRequest= WebRequest.Create("http://192.168.200.192:8888/press/bank/13/2") dim response3 As WebResponse = client3.GetResponse() response.Close API.Function("SelectTitlePreset",Input:="MESSAGE TO MONITOR", Value:= 0) Sleep (500)
|
|
|
|
vMix Forums
»
General
»
General Discussion
»
Http Request inside of vMix Script
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close