logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
obcocav  
#1 Posted : Monday, September 27, 2021 1:49:43 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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!
doggy  
#2 Posted : Monday, September 27, 2021 2:14:54 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,223
Belgium
Location: Belgium

Thanks: 293 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: obcocav Go to Quoted Post


This syntax does not work as part of another script though. Only standalone.




What do you mean ?


obcocav  
#3 Posted : Monday, September 27, 2021 2:19:30 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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.
doggy  
#4 Posted : Monday, September 27, 2021 2:39:23 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,223
Belgium
Location: Belgium

Thanks: 293 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: obcocav Go to Quoted Post
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#post70833

btw 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
obcocav  
#5 Posted : Monday, September 27, 2021 9:52:18 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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
doggy  
#6 Posted : Monday, September 27, 2021 2:47:34 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,223
Belgium
Location: Belgium

Thanks: 293 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: obcocav Go to Quoted Post
@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
obcocav  
#7 Posted : Tuesday, September 28, 2021 9:44:56 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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).
obcocav  
#8 Posted : Tuesday, September 28, 2021 10:45:40 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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
Peter1000  
#9 Posted : Tuesday, September 28, 2021 4:55:08 PM(UTC)
Peter1000

Rank: Advanced Member

Groups: Registered
Joined: 1/25/2019(UTC)
Posts: 303
Switzerland

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
thanks 1 user thanked Peter1000 for this useful post.
doggy on 9/28/2021(UTC)
doggy  
#10 Posted : Tuesday, September 28, 2021 4:56:16 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,223
Belgium
Location: Belgium

Thanks: 293 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: obcocav Go to Quoted Post


As to the SelectTitlePreset...Here you go.



Yup which is NOT the same as SetTitlePreset ;-)
obcocav  
#11 Posted : Thursday, September 30, 2021 3:45:36 AM(UTC)
obcocav

Rank: Member

Groups: Registered
Joined: 7/18/2020(UTC)
Posts: 18
United States
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)
Users browsing this topic
Guest
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.