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/10/16 06:50] – [Changes shape color of a specific shape, e.g. a circle or a rectangle) (Setcolor)] 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 504: Line 523:
  
 ===== Fetches the color of a shape from a GTtitle and then performs an action based on the color ===== ===== 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>
 +
 +
  
 ===== Increase or decrease a numerical value in a textfield at the touch of a button ===== ===== Increase or decrease a numerical value in a textfield at the touch of a button =====
scripting_examples.1697431838.txt.gz · Last modified: 2023/10/20 19:45 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki