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:57] – [Fetches the color of a shape from a GTtitle and then performs an action based on the color] 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 507: Line 526:
 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.  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}}. 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 <code>do while true  'loop indefinite
Line 515: Line 541:
 x.loadxml(xml) x.loadxml(xml)
  
-Define the title and text field you're interested in as strings+define title and text field for searching color
 Dim TITLE As String = "textshape.gtzip" Dim TITLE As String = "textshape.gtzip"
 Dim SHAPE As String = "Shape.Fill.Color" Dim SHAPE As String = "Shape.Fill.Color"
 Dim TEXTFIELD as string ="Text.Text" Dim TEXTFIELD as string ="Text.Text"
  
-Construct the XPath to locate the color element within the input element+ XPath to locate color element and input element
 Dim xpath As String = "//input[@title='" & TITLE & "' and color[@name='" & SHAPE & "']]/color[@name='Shape.Fill.Color']" Dim xpath As String = "//input[@title='" & TITLE & "' and color[@name='" & SHAPE & "']]/color[@name='Shape.Fill.Color']"
  
-Select the color element using the constructed XPath+select color element using the XPath
 Dim colorNode As System.Xml.XmlNode = x.SelectSingleNode(xpath) Dim colorNode As System.Xml.XmlNode = x.SelectSingleNode(xpath)
  
-Get the color value from the shape+get color value from shape
 Dim colorValue As String = colorNode.InnerText Dim colorValue As String = colorNode.InnerText
  
-Output the color value to the textfield in the sample gtzip file+'output color value to textfield in sample gtzipTitle
 'API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:=colorValue ) 'API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:=colorValue )
  
Line 540: Line 566:
 API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:="NOT WHITE" ) API.Function("SetText",Input:=TITLE,SelectedName:=TEXTFIELD,Value:="NOT WHITE" )
 end if end if
-sleep(1000) 'waits one second to loop+sleep(1000) 'waits second to loop
 loop  loop 
 </code> </code>
scripting_examples.1697432254.txt.gz · Last modified: 2023/10/20 19:45 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki