Skip to content

Instantly share code, notes, and snippets.

@imorrish
Created October 14, 2018 07:24
Show Gist options
  • Save imorrish/0eac59207b95dbe7187ef57e358b2ef5 to your computer and use it in GitHub Desktop.
Save imorrish/0eac59207b95dbe7187ef57e358b2ef5 to your computer and use it in GitHub Desktop.
Send play and stop commands when ATEM switches to/from an input
$monitor=3 #ATEM input to trigger play and stop
function ConnectToATEM()
{
Try{
$ATEMipAddress = (Get-ItemProperty -path 'HKCU:\Software\Blackmagic Design\ATEM Software Control').ipAddress
$DocumentsPath = [Environment]::GetFolderPath("MyDocuments") + '\windowspowershell\SwitcherLib.dll'
add-type -path $DocumentsPath
$Global:atem = New-Object SwitcherLib.Switcher($ATEMipAddress)
$atem.Connect()
}
catch{
write-host "Can't connect to ATEM on $($ATEMipAddrss)."
Write-Host "ATEM controle software must be installed and have connected to switcher at least one time"
exit
}
}
ConnectToATEM
$me=$atem.GetMEs()
$Global:me1=$me[0]
$Global:Program = $me1.program
do{
[Int32]$CurrentProgram = $Global:me1.Program # | get-member
if($Global:Program -ne $CurrentProgram){
if($CurrentProgram -eq $monitor){
#Play
write-host "Play"
}
elseif($Global:Program -eq $monitor){
#Stop
write-host "Stop"
}
$Global:Program = $CurrentProgram
}
start-sleep -Milliseconds 10
}while($true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment