Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
For creating a script go to Settings->Scripting All further Logics are in vb.net
Any reference to API.XML() is what one can find/see at http://127.0.0.1:8088/api (or local IP)Further details are in the Help Files which can be accessed by clicking the question mark (?) in the top right corner of your vMix window One can call a script using a shortcut or a Trigger with the function "ScriptStart"Code:'doing some input controls
Input.Find("YourInput").Function("Cut")
API.Function("Pause",Input:=10)
Code:'See Shortcuts to get idea of elements used in a function
'SelectedName (or SelectedIndex) instead of Title seen in Shortcut creation options
'Change an image in a title
API.Function("SetImage",Input:="SomeTitle.gtzip",SelectedName:="Image1.Source",Value:="c:/fotoname.png")
'Change/Add the input of a multilayer Input
API.Function("SetMultiViewOverlay",Input:="InputWithMultiview",Value:="3,inputnameToAddToLayer3")
Code:'Is a input Running or on Pause retrieved from the API xml
dim xml = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim StateOf = (x.SelectSingleNode("//input[@type='Replay']/@state").Value)
'or
dim StateOf = (x.SelectSingleNode("//input[@number='10']/@state").Value)
Console.WriteLine(StateOf)
Code:'wait for a second in a script :-)
Sleep(1000)
Code:'çhecking if a file exists based on the name in the TextBlock Headline.Text of a title
dim FILELOCATION As string = "D:/"
dim IMAGENAME As string = ""
dim FILENAME As string = ""
IMAGENAME = Input.Find("TitleName").Text("Headline.Text")
FILENAME = FILELOCATION & IMAGENAME & ".png"
If System.IO.File.Exists(FILENAME) Then
'write to the console of the scripteditor
Console.WriteLine("The file allready exists")
else
Console.WriteLine("Nope")
end if
|
15 users thanked doggy for this useful post.
|
tomaszek117 on 1/6/2020(UTC), stevespaw on 1/6/2020(UTC), stigaard on 1/8/2020(UTC), cho123 on 4/10/2020(UTC), avsoundguy on 5/8/2020(UTC), DWAM on 5/23/2020(UTC), studiodelta on 9/6/2020(UTC), CamStol on 11/13/2020(UTC), worldeye on 11/25/2020(UTC), stergi on 4/8/2021(UTC), hardayildiz on 8/20/2021(UTC), filipe.shakeit on 10/8/2021(UTC), jpetrie on 12/30/2021(UTC), nikosman88 on 1/11/2022(UTC), Ario on 1/6/2023(UTC)
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
A few links to scripting related posts in case a forum search didn't work
|
8 users thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 3/17/2017(UTC) Posts: 424 Location: Luzern - Schweiz Thanks: 63 times Was thanked: 55 time(s) in 49 post(s)
|
404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Originally Posted by: elvis55 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Should be fixed
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
They all do the same thing ;-)
Shortcut, Http Web API , Scripting To change a text in a title as example Shortcut Shortcut.JPG (106kb) downloaded 27 time(s).NOTE: 'Title' becomes 'SelectedName' or 'SelectedIndex' depending if you use the reference name or it position(index) HTTP Web API in Browser Code:http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Some Text
<! or >
http://127.0.0.1:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=Some Text
ScriptingCode:
'VB.net
Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "Some Text"
'API
API.Function("SetText",Input:="1",SelectedName:="Headline.Text",Value:="Same Text")
'WEB
Function=SetText&Input=1&SelectedIndex=0&Value=Some Other Text
'HTTP
Dim client = WebRequest.Create("http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Some Text")
Dim response = client.GetResponse()
response.Close
|
2 users thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/3/2013(UTC) Posts: 117 Location: Arizona
Thanks: 8 times Was thanked: 6 time(s) in 6 post(s)
|
Thanks for posting this it has helped me immensely! I'm pretty versed on scripting native vmix commands now.
How would one script for watching a data source change?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Quote:How would one script for watching a data source change? Would need to be more specific !
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/3/2013(UTC) Posts: 117 Location: Arizona
Thanks: 8 times Was thanked: 6 time(s) in 6 post(s)
|
Here's what I'm working with.... Ideally, I would like the white bar to fade in when the results change. Currently the data resides in a google sheet, but will more than likely go back to an xml. I would like it to auto next through the sheet and fade out once the ticker scrolls the last line of data. I have used a script to fade out after a certain number of data rows have shown but the number of rows changes often and we are having to calculate them manually and input the delay manually. I was having to fade in and out manually and its just too time-consuming to use in production. If anyone wants to take a look at the actual project everything can be downloaded at https://usabmx.sharefile.com/d-s8d939c5f4284067a
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Quote:Ideally, I would like the white bar to fade in when the results change. Wrong place to ask , this is title related. Advice is to check out the GT title tutorial videos etc (workign with data sources, data change ... all have videos about it When number of rows changes you need to make a test in a script. Advice is look up some vb.net tutorials on how to loop through something until a criteria is met , That's the whole point of scripting , taking manual decision making away from you Be aware of using the right terms in a post : titles, textblocks, tickers to not create confusions WHy use green background ? Where is your ticker ? ( a textbox with a scroll animation is NOT a ticker be it simulates one )
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/3/2013(UTC) Posts: 117 Location: Arizona
Thanks: 8 times Was thanked: 6 time(s) in 6 post(s)
|
I'm only looking for scripting help that will trigger the fade actions.
There are two inputs in vmix at play here. basic_transfers.xaml Ticker 3-Clear.gtzip Ticker 3-Clear.gtzip sits on top of basic_transfers.xaml. Originally I had these two combined in a single GT title but was having issues with the datachange ticker animation. In a bind, I separated them. Both read from the same data source. Column 1 feeds basic, column 2 feeds the ticker. Ideally, I would like to have both fade in when new data is added to the google sheet and fade out when the final line of data is displayed. Hope that makes sense.
The green background was added to feed this out of vmix into an older switcher that was in the venue.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Not limited for checking recording status ;-) Code:' Checking recording status from the API xml (127.0.0.1:8088/API)
' and display in a Title Input
dim isrecording as string = ""
'lets keep checking
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
'are we recording?
isrecording = (x.SelectSingleNode("//recording").InnerText)
'used at debugging stage
console.writeline(isrecording)
'put a response in a title and change color accordingly
if isrecording = true
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="RECORDING in PROGRESS")
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
else
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="ALL CLEAR")
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
end if
sleep(500)
loop
am sure it can be improved
|
2 users thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/3/2013(UTC) Posts: 117 Location: Arizona
Thanks: 8 times Was thanked: 6 time(s) in 6 post(s)
|
Originally Posted by: doggy Not limited for checking recording status ;-) Code:' Checking recording status from the API xml (127.0.0.1:8088/API)
' and display in a Title Input
dim isrecording as string = ""
'lets keep checking
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
'are we recording?
isrecording = (x.SelectSingleNode("//external").InnerText)
'used at debugging stage
console.writeline(isrecording)
'put a response in a title and change color accordingly
if isrecording = true
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="RECORDING in PROGRESS")
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
else
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="ALL CLEAR")
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
end if
sleep(500)
loop
am sure it can be improved Was this for me?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Originally Posted by: g-mo
Was this for me?
If you feel you can use it yes, but not specifically ? Point of this thread it to give some leads and as extension to the help files . I am far from an expert but to me the small examples helped me figure out more complete solutions just as fellow forum members have and still give me leads to achieve a solution so i hope they help you all. Even if a specific function does not exist the fun is to figure out a way to achieve the same result it by looking outside the box sometimes. I don't feel the need to post/give away complete scripts to specific wishes posted here or elsewhere in this forum even if i managed to make them as even then i had to search and try to complete them even when i might never use them myself but they do prove its possible and that's the "fun" part ;-). And there is no harm in posting your own little tidbits you discovered ;-)
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
From a recent request/discussion: Goal: to switch 2 ACTIVE PIP overlays on screen with one shortcut Individual overlay replacing or activating/deactivating as usual Code:' OVERLAYS SET TYPE = PIP AND EFFECT = CUT.
' Nothing holding you back to choose another effect
'lets have basket to hold some info
dim xml as string = API.XML()
dim ovl1input as string = ""
dim ovl2input as string = ""
'lets get all API xml data (http://127.0.0.1:8088/api)
dim x as new system.xml.xmldocument
x.loadxml(xml)
' let's see which of you inputs is currently on PIP overlays
ovl1input = (x.SelectSingleNode("//overlays//overlay[1]").InnerText)
ovl2input = (x.SelectSingleNode("//overlays//overlay[2]").InnerText)
if (ovl1input = nothing) or (ovl2input = nothing)
'we don't have 2 PIP overlays, no point in continuing then
return
end if
' lets switch you both
API.Function("OverlayInput1In",Input:=ovl2input)
sleep(50)
API.Function("OverlayInput2In",Input:=ovl1input)
'we are all good now ?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
From a recent request/discussion to trigger something BEFORE a video finishes Code:' Checking time left of active input
' and do some stuff at certain time remaining
dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 2000 '2 seconds before end
dim triggerduration as integer = 2000 'fade duration, could be different than trigger
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)
Timeleft= Double.Parse(duration)-Double.Parse(position)
if Timeleft < triggertime
API.Function("SetVolumeFade",Input:=activeinput.tostring(),Value:="0," & triggerduration.tostring())
' do whatever one wants to do
end if
sleep(500)
Loop
|
5 users thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Retrieve the name of a vMix Video CallerMost Basic Form Code:
'get name of caller @ Input 1
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim word as string = (x.SelectSingleNode("//input[@number=1]").InnerText)
console.writeline(word) 'or API to send to title
sleep(500)
loop
Other option to retrieve them all through a xml datasource with xpath: //input[@type="VideoCall"]
|
2 users thanked doggy for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 4/9/2020(UTC) Posts: 13 Location: Daarlerveen Thanks: 4 times Was thanked: 7 time(s) in 1 post(s)
|
So based on 2 programs above from Doggy, I made a Video player time left title display that you can add on top of the Clock source by using the Multiview to stack upon. While the code is not 100% perfect yet and only displays MM;SS But it gives you some idea and it's workable. Till 60 seconds it's green, Turns then orange, and the last 10 seconds it's red. Code:' Checking time left of active running video and display this as an title.
' and do some stuff at certain time remaining
dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 10 '10 seconds before end
dim triggerduration as integer = 2000 'fade duration, could be different than trigger
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)
Timeleft= Double.Parse(duration)-Double.Parse(position)
Timeleft = Timeleft / 100
dim Timingleft as integer = CInt(Timeleft)
Timingleft = Timingleft / 10
dim Minutes as integer = Timingleft \ 60
dim Seconds as integer = Timingleft Mod 60
'used at debugging stage
' console.writeline(Timingleft)
' console.writeline(Seconds)
dim ThisTime as string
ThisTime = Minutes.ToString("00") + ":" + Seconds.ToString("00")
if Timingleft < 60
'put a response in a title and change color accordingly
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=Timingleft) ' Value:=":", Value:=Seconds)
if Timingleft < 30
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
else
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="orange")
end if
else
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=ThisTime)
API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
end if
sleep(50)
Loop
|
7 users thanked Xtreemtec Media for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Trigger a function at specific time of day
Code:'Trigger a function at a specific time of day
dim triggertime as string = "06:56"
'console.writeline ( DateTime.Now.ToString("hh:mm"))
Do While True
If triggertime = DateTime.Now.ToString("hh:mm") Then
' The times match so do something like
API.Function("OverlayInput1In",Input:="1") 'replace 1 with the to overlay input nr
' And we are done
Exit do
End If
sleep(1000)
Loop
EDIT: change hh:mm to HH:mm for 24hr clock
|
7 users thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 5/15/2020(UTC) Posts: 33 Thanks: 1 times
|
Hi everyone, I'm really stuck on a little script that I wrote to fade in/out an input with the alpha value. Unfortunately the API command doesn't get executed as soon as I put it inside a For next loop. What am I doing wrong here? Code:
for i as integer = 255 to 0
API.Function ("SetAlpha",Input:=2,Value:=i)
i=i-1
next
If I comment the for/next loop out the API.Function works. Any hint? Thanks for your help!
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,230 Location: Belgium Thanks: 293 times Was thanked: 957 time(s) in 792 post(s)
|
Originally Posted by: streaming---pro Hi everyone, I'm really stuck on a little script that I wrote to fade in/out an input with the alpha value. Unfortunately the API command doesn't get executed as soon as I put it inside a For next loop. What am I doing wrong here? Code:
for i as integer = 255 to 0
API.Function ("SetAlpha",Input:=2,Value:=i)
i=i-1
next
If I comment the for/next loop out the API.Function works. Any hint? Thanks for your help! For next has to go up unless you tell it to step down! and changing the i value within the loop is not a good idea as the loop already does that Google "for loops counting down" for the solution
|
|
|
|
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