Running Characterworks graphic from JustMacros? (SOLVED)

Questions about ATEM Switchers, Camera Converter and everything live!
  • Author
  • Message
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Running Characterworks graphic from JustMacros? (SOLVED)

PostThu Apr 19, 2018 1:15 pm

Hi!
I usually find what I´m looking for on AtemUser when I need help, tips & tricks regarding JustMacros. But the site seems to be down. Trying my luck here. Bear with me.
So: we run a couple of hotkey macros for setting up supersources and some other stuff in ATEM control.
Now I´m looking into sending commands also to our CG-system, Characterworks.
CW responds to JSON-type commands with http post. It doesn seem as if JM can do this? Or can it (first question)?
What I´ve succeeded in is creating a PowerShell script that can trigger graphics in CW. This can be run as an executable on the PC i run ATEM and JM and from there trigger graphic on the CW computer. So maybe a workaround is to have JM run the Powershell script as a program/exe/bat in the same macro that controls the ATEM mixer. Anyone done something like this?
Last edited by Torbjörn Lindström on Wed Apr 25, 2018 11:50 am, edited 1 time in total.
Offline
User avatar

Tom_Bassford

  • Posts: 1665
  • Joined: Wed Aug 22, 2012 8:12 am
  • Location: Europe / UK

Re: Any JustMacros wizards out there?

PostThu Apr 19, 2018 1:32 pm

I think you can do basic json requests using the “generic comms” modules.

Sorry about how broken atemuser is. It’s taking a lot more work to fix than I was hoping.


Sent from my iPhone using Tapatalk
http://www.atemuser.com
if it was easy it wouldn't be called engineering
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostThu Apr 19, 2018 1:43 pm

To clearify a bit (hopefully) what I´m messing with:
Here is a powershell script that works in that it starts the scroller in characterworks (pc is on the url i´ve blanked.). It is the first two rows that are specific for controlling CW. The rest is powershell coding I´ve got help figuring out.
So: would there be any way to code this in JustMacros? Or run the Powershell script-file from JM?

$url = "http://xxxxxx:5201"
$command = '{ "action" : "play_motions", "motions" : [ "SCROLLER_1" ],"channel" : "live1" }'
$bytes = [System.Text.Encoding]::ASCII.GetBytes($command)
$web = [System.Net.WebRequest]::Create($url)
$web.Method = "POST"
$web.ContentLength = $bytes.Length
$web.ContentType = "application/x-www-form-urlencoded"
$stream = $web.GetRequestStream()
$stream.Write($bytes,0,$bytes.Length)
$stream.close()


EDIT:
I´ve also created a .bat file that runs the above PS-script. If it is possible to run bat files from JM this would do the trick. Kan the JM command "TaskManGKSCRunAsAdmin"do this and if so what is the proper scripting?
Offline

Ian Morrish

  • Posts: 580
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Any JustMacros wizards out there?

PostThu Apr 19, 2018 8:29 pm

You can run the PowerShell direct from JM. I have a post about how to do this on AtemUser :-(
You can simplify your code below if using Windows 10 (or upgrade WinRM on Windows 7 to get PowerShell 5.0) to

$command = '{ "action" : "play_motions", "motions" : [ "SCROLLER_1" ], "channel" : "live1" }'
Invoke-RestMethod -Uri “http://localhost:5201/” -Method POST -Headers $headers -ContentType “application/json” -Body $Command

As noted in https://ianmorrish.wordpress.com/2017/03/01/automating-characterworks-from-powershell/
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 3:29 am

Ian Morrish wrote:You can run the PowerShell direct from JM. I have a post about how to do this on AtemUser :-(
You can simplify your code below if using Windows 10 (or upgrade WinRM on Windows 7 to get PowerShell 5.0) to

$command = '{ "action" : "play_motions", "motions" : [ "SCROLLER_1" ], "channel" : "live1" }'
Invoke-RestMethod -Uri “http://localhost:5201/” -Method POST -Headers $headers -ContentType “application/json” -Body $Command

As noted in https://ianmorrish.wordpress.com/2017/03/01/automating-characterworks-from-powershell/
Great news, Ian! Thanks! Just hope AtemUser comes back to life soon so I can read your post :-)

Skickat från min BLA-L29 via Tapatalk
Offline

Ian Morrish

  • Posts: 580
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 5:30 am

In PowerShell, you have to enble running of script files (by default only runs commands in the console).
Do this by running PowerShell as Administrator. The type command

Set-ExecutionPolicy remotesigned

In JM, use command (note: the double \'s)

TaskManGKSCWinMin("PowerShell -command c:\\path_toYourScript\\PlayLive1.ps1");
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 7:59 am

Thank you so much for this, Ian. I owe you a cold one (or two)!

I actually have played around with that JM-command but never got it working. Didn´t know about the double \ 's :)
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 8:25 am

Hmm. It won´t work. When running the string from JM I can se Powershell starting but it doesn´t run the script in the ps1 file (which works if I run it directly in PS).

Seems as Powershell doesn´t find the ps1 - file.
I have run the command to execute remotely in PS

Here is what I run in JM:
TaskManGKSCWinExecMin ("PowerShell -command c:\\foldername\\scroller_1.ps1")

Should there be some more citation marks or so?

Googled about running powershell ps1-files and found some samples like these:

powershell.exe -Command "& 'C:\Users\test\Documents\Test Space\test.ps1'"

Here there´s both single and double quotation marks in the powershell path.
Should these be added in the JM-scripting and if so how?

Edit: can this be a feature that only works in pro version of JM?
Offline

Ian Morrish

  • Posts: 580
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 7:45 pm

Just tested it fin
Image
I am using an old version of the free edition JustMacros63Plus.exe so don't know if the new version blocks this feature for free users but I doubt it.
May be that the script has an error but windows closes so fast you don't notice it.

My test script just has the following

write-output "hi"
start-sleep 20
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostFri Apr 20, 2018 11:23 pm

Ian Morrish wrote:Just tested it fin
Image
I am using an old version of the free edition JustMacros63Plus.exe so don't know if the new version blocks this feature for free users but I doubt it.
May be that the script has an error but windows closes so fast you don't notice it.

My test script just has the following

write-output "hi"
start-sleep 20
Thanks! I'll keep trying when I'm back at work on Monday.
So weird though that the PS1 script works fine when I run it directly with Powershell but not when I trigger powershell through JM.

Skickat från min BLA-L29 via Tapatalk
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostMon Apr 23, 2018 10:37 am

Plot thickens...
On my laptop I got it working and can run a PS1 script file with Powershell from Justmacros, that runs a graphic on Characterworks pc.
But if I try to do exactly the same thing with JM on another pc (same command string in JM, PS1 file on same path, same execution policy etc) it won't run the same PS1 file.
Seems as if Powershell doesn't recognize the file or path or isn't allowed to run it.

But if I right click on the PS1 file and choose "run with Powershell" on that pc the script works :-/...

Help please!


Skickat från min BLA-L29 via Tapatalk
Offline

Torbjörn Lindström

  • Posts: 129
  • Joined: Tue Aug 20, 2013 2:43 pm

Re: Any JustMacros wizards out there?

PostTue Apr 24, 2018 2:56 pm

Problem solved!
The problem was how the Execution Policy was or was not set in powershell on the production PC that run JustMacros.
Just running the "set-executionpolicy Unrestricted" in powershell did work on my personal laptop.
But apparently that sets the policy for "LocalMachine" only.
To get the JM command working on the production PC I needed to also set the policy for "CurrentUser" with a powershell command like:
"Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted"

...and boom: a world of new possibilites to control CG with justmacros!

Hope this can be of help for others out there running CharacterWorks, ATEM and Justmacros

Return to Live Production

Who is online

Users browsing this forum: Bing [Bot], DoorKnob4531 and 42 guests