Scripting a Capture from an external source

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Scripting a Capture from an external source

Postby matthewwachter » Fri Jun 28, 2019 11:38 pm

I understand that this category is reserved for Apple users using AppleScript but I'm not really sure which category would be more relevant for this question; maybe someone can point me in the right direction.

My goal is to trigger a camera capture from an external source. Ideally this would be a TCP or OSC message but there are a variety of other protocols that would work for my application. Is there any way to do this? From what I understand, the only way to capture is directly from the physical camera buttons, the button in the interface, or a user-defined keyboard shortcut (ctrl-k by default).

My current solution is to use the Python keyboard module (https://pypi.org/project/keyboard/) to simulate a keypress. This works but it requires the program to be selected and it's a bit of a hack. Of course another solution would be to use the physical remote trigger on the camera and use some type of micro-controller like an Arduino to close the switch but I thought someone might have a better solution here.

Is there a way to do this that I'm just missing or would it be possible to write a plugin using the SDK that has this type of functionality?

Thanks!
matthewwachter
 
Posts: 3
Joined: Wed Dec 12, 2018 9:21 pm

Re: Scripting a Capture from an external source

Postby matthewwachter » Tue Jul 16, 2019 5:22 pm

Just wanted to share the Python keyboard module solution here.

Code: Select all
import keyboard

keyboard.press_and_release('ctrl+k')


Pretty simple but still not ideal. Anyone have any suggestions?
matthewwachter
 
Posts: 3
Joined: Wed Dec 12, 2018 9:21 pm

Re: Scripting a Capture from an external source

Postby Jim_DK » Tue Jul 16, 2019 9:33 pm

Hello,

This problem/solution assumes the camera is always on and tethered to a Mac?
Jim_DK
Crew
Crew
 
Posts: 658
Joined: Thu Dec 03, 2009 10:00 pm

Re: Scripting a Capture from an external source

Postby matthewwachter » Wed Jul 17, 2019 5:46 pm

Yes, this would assume the camera is on and tethered but not specifically to a Mac. I understand that the Scripting category is for Apple users but it seems like this functionality should be os agnostic. The python code I posted would definitely work across platforms.
matthewwachter
 
Posts: 3
Joined: Wed Dec 12, 2018 9:21 pm

Re: Scripting a Capture from an external source

Postby Eric Nepean » Wed Jul 17, 2019 5:57 pm

You can simulate a keypress in Applescript like this
Code: Select all
tell application "TextEdit" to activate
tell application "System Events"
    keystroke "abc 123"
end tell
More references on this
https://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript
https://apple.stackexchange.com/questions/142986/applescript-keystroke-ignoring-numbers?noredirect=1&lq=1

However Applescript doesn't have a direct interface to the Mac's Network Interfaces.

From another Mac you could trigger the Keypress Applescript to run, like this
https://www.makeuseof.com/tag/remotely-control-mac-simple-applescripts/

There seem to be few OSC applications for OSX, and I don't see one that can trigger ascript of anykind.
You could log into the Mac using SSH, and the remotely run a keypress script. A bit too low level for this solution I think.

Otherwise you need something with a network interface that can
  • Call an Applescript Script when it receives a TCP message (receiver side)
  • Send a TCP message in response to a mouse click or keypress (controller side)

There is a page here with some comments on writing a UNIX script which reacts to a TCP message and could call an Applescript
https://unix.stackexchange.com/questions/314550/how-to-set-a-script-to-execute-when-a-port-receives-a-message
Eric Nepean
 
Posts: 615
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: Scripting a Capture from an external source

Postby rapdigital » Wed Jul 17, 2019 10:12 pm

There are a lot of 'you could' answers but without knowing a little more about what you are hoping to achieve it not necessarily what you should do.

for instance AS has a direct connection to capturing with CO.

Code: Select all
tell application "Capture One 12"
   capture
   delay 1 -- wait for capture to finish
end tell


But running AS remotely is a PITA in 10.14 because of the security changes of recent.

Have you had a look at PiCameraControl there are a couple Pi camera control projects that might be worth looking at.
rapdigital
Certified Professional
Certified Professional
 
Posts: 182
Joined: Mon Feb 02, 2009 1:52 pm


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest