User Tools

Site Tools


scripting_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting_examples [2023/04/19 14:01] – [All characters to the right of the colon] peteraelligscripting_examples [2023/11/15 16:59] (current) – [turns off all SOLOs] peteraellig
Line 237: Line 237:
   API.Function("AudioBusOff", i, "D")   API.Function("AudioBusOff", i, "D")
 Next</code>\\ Next</code>\\
 +
 +
 +===== turns off all SOLOs =====
 +<code>'switch off all solos on busses
 +Dim busValues As String() = {"A", "B", "C", "D", "E", "F", "G"}
 +For Each value As String In busValues
 +    API.Function("BusXSoloOff", Value:=value)
 +Next
 +
 +'switch off all solos on inputs
 +Dim xmlDoc As New XmlDocument()
 +Dim i as integer
 +xmlDoc.LoadXml(API.Xml)
 +Dim inputNodes As XmlNodeList = xmlDoc.SelectNodes("/vmix/inputs/input")
 +Dim inputCount As Integer = inputNodes.Count
 +for i = 1 to inputcount
 +  API.Function("SoloOff", i)
 +Next
 +</code>\\
  
 ===== gets Audio Titelname from a INPUT (Musictitle) ===== ===== gets Audio Titelname from a INPUT (Musictitle) =====
Line 260: Line 279:
 dim x as new system.xml.xmldocument dim x as new system.xml.xmldocument
 x.loadxml(xml) x.loadxml(xml)
-dim word as string = x.SelectSingleNode("//input[@number=[h]'2'[/h]]/@title").Value+ 
 +'gets active title from the playlist 
 +dim word as string = (x.SelectSingleNode("//input[@number=2]/@title").InnerText) 
 + 
 +'removes .mp3 from the title
 word = word.remove(word.Length - 4) word = word.remove(word.Length - 4)
-dim wordArr as String() = word.Split("-"+ 
-Dim result0 as String wordArr(0) +' Split the string by "-" 
-Dim result1 as String = wordArr(1) +Dim parts() As String = word.Split(New Char() {"-"c}, StringSplitOptions.RemoveEmptyEntries
-Dim result2 as String wordArr(2) + 
-Dim result3 as String = wordArr(3+' Trim each part to remove leading and trailing spaces 
-Dim result4 as String wordArr(4) +For i As Integer = 0 To parts.Length - 1 
-dim fullname as string =  result1 + " " + result2 + " " + result4  +    parts(i) = parts(i).Trim() 
-API.Function("SetText",Input:="Title 33On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result1) +Next 
-sleep(1000) + 
-API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result2) +'gets number of parts 
-sleep(1000) +Dim number As Integer parts.Length -1 
-API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result4) + 
-sleep(1000) +'shows each part of the tile for a second 
-API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=fullname)+for ii as integer 1 to number 
 +API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=parts(ii))
 sleep(1000) sleep(1000)
 +next
 loop</code> loop</code>
  
Line 496: Line 521:
 via HTTP API via HTTP API
 <code>http://127.0.0.1:8088/api/?Function=SetColor&Input=clocks.gtzip&SelectedName=background.Fill.Color&Value=%23FFFF00</code>\\ <code>http://127.0.0.1:8088/api/?Function=SetColor&Input=clocks.gtzip&SelectedName=background.Fill.Color&Value=%23FFFF00</code>\\
 +
 +===== Fetches the color of a shape from a GTtitle and then performs an action based on the color =====
 +
 +This is a script that shows how to read the color of a shape from a title and then perform an action based on the color. The script must be started and runs in the background as a loop. 
 +the title used in the example can be downloaded {{ ::textshape.gtzip |here}}.
 +{{:gsc3.jpg?200|}}\\
 +
 +gets the color value of a shape in a gtzip-title:\\
 +{{:gsc1.jpg?200|}}\\
 +and writes the value in the Text.Text field\\
 +{{:gsc2.jpg?200|}}\\
 +
 +
 +<code>do while true  'loop indefinite
 +
 +'load the XML data from vMix
 +dim xml as string = API.XML()
 +dim x as new system.xml.xmldocument
 +x.loadxml(xml)
 +
 +' define title and text field for searching color
 +Dim TITLE As String = "textshape.gtzip"
 +Dim SHAPE As String = "Shape.Fill.Color"
 +Dim TEXTFIELD as string ="Text.Text"
 +
 + XPath to locate color element and input element
 +Dim xpath As String = "//input[@title='" & TITLE & "' and color[@name='" & SHAPE & "']]/color[@name='Shape.Fill.Color']"
 +
 +' select color element using the XPath
 +Dim colorNode As System.Xml.XmlNode = x.SelectSingleNode(xpath)
 +
 +' get color value from shape
 +Dim colorValue As String = colorNode.InnerText
 +
 +'output color value to textfield in sample gtzipTitle
 +'API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:=colorValue )
 +
 +
 +if colorValue = "#FFFFFF" then 'white
 +'do something
 +API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:="WHITE" )
 +else
 +'do something other
 +API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:="NOT WHITE" )
 +end if
 +sleep(1000) 'waits 1 second to loop
 +loop 
 +</code>
  
  
Line 1253: Line 1326:
 </code> </code>
  
-===== Ersetze einen bestimmten Textteil durch einen anderen =====+===== Replace a certain part of the text with another one =====
  
 <code>Dim originalstring As String <code>Dim originalstring As String
 originalstring = "0xff0000" originalstring = "0xff0000"
  
-Ersetze "0x" mit ""+replace "0x" with ""
 Dim newString As String = originalstring.Replace("0x", "") Dim newString As String = originalstring.Replace("0x", "")
-' die Variable newString enthält  "ff0000"+' die Variable newString contains "ff0000"
 </code> </code>
  
-===== Lösche alle Leerzeichen am Anfang und am Ende einer Zeichenkette =====+===== Delete all spaces at the beginning and at the end of a string =====
 <code>Dim originalstring As String <code>Dim originalstring As String
 originalstring = " Peter, Paul und Marry haben: 455 Franken  " originalstring = " Peter, Paul und Marry haben: 455 Franken  "
  
 Dim newString As String = originalstring.Trim() Dim newString As String = originalstring.Trim()
-die Variable newString enthält  "Peter, Paul und Marry haben: 455 Franken"+the Variable newString contains "Peter, Paul und Marry haben: 455 Franken"
 </code> </code>
  
Line 1294: Line 1367:
  
 <code> <code>
-delete files in folder+'delete files in folder
 Dim path As String = "C:\Testdir" Dim path As String = "C:\Testdir"
  
scripting_examples.1681905718.txt.gz · Last modified: 2023/10/20 19:45 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki