How to run Automator app using AppleScript?

I'm trying to use Remote Buddy to control Photo Booth, but I need a way to switch between Still and Video modes, my solution for this was to use the Automator application to select one or the other of the two switches when I press the remote control button.

I created a .app file and it works fine when I double-click it on the desktop, but I need a way to run .app from Remote Remote, and AppleScript seems to be my only option.

TL; dg

I need to run the Automator.app file using AppleScript, but cannot determine the correct syntax.

+4
source share
4 answers

If I made an Automator application called Untitled , I would start it with this command tell application "Untitled" to activate

Once you create an application using one of the following methods, this application can be obtained in any other script through its name. It is defined globally, like any other application on your mac. Just use tell application "app Name"

Two ways to create an application: Using AppleScriptUsing automator

+4
source
 activate app ((system attribute "HOME") & "/Desktop/test.app/") 

You can also use the automator shell automator .

 automator test.workflow automator test.app automator test.workflow -v # verbose automator -i lol test.workflow echo lol | automator -i - test.workflow automator -i $'lol\nlol2' test.workflow # \n separates input strings automator -d somevar=somevalue test.workflow 
+3
source

First you should name your application for automator, for example, "photobooth.app", then you will use the applescript type in

 tell application "photobooth.app" activate end tell 
0
source

I do this directly using Automator scripts. This does not have access to the application, but rather to the workflow. This is beneficial because you can edit the settings / contents of some individual workflow elements.

I believe my answer is better for the question:

How to start an Automator workflow using AppleScript?

I believe that keeping Automator action at first helps avoid problems. eg.

 set theWorkflowName to "Merge PDF Files" set myWorkflow to make new workflow with properties {name:theWorkflowName, path:POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string)} set myWorkflow to open POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string) 

Merge PDF Files

 on open the_Droppings -- CONVERT INPUT LIST OF ALIASES TO POSIX PATHS repeat with itemStep from 1 to count of the_Droppings set item itemStep of the_Droppings to POSIX path of item itemStep of the_Droppings end repeat tell application "Automator" activate set myWorkflow to open POSIX file "/Users/USERNAME/Dropbox/Scripts/Automator/Workflows/merge PDF files.workflow" set actionsList to name of Automator action of myWorkflow set firstAction to item 1 of actionsList tell myWorkflow (* get index of Automator action firstAction get input types of Automator action firstAction get path of Automator action firstAction get path of Automator action firstAction get value of setting of Automator action firstAction *) set value of setting of Automator action firstAction to the_Droppings -- MUST BE LIST OF POSIX PATHS end tell end tell end open 
0
source

All Articles