Running an Automator file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Running an Automator file

Post by Mag » Wed Mar 19, 2014 10:49 pm

Is it possible to run/launch an Automator .workflow file from within LC? ... and how? :oops:

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Running an Automator file

Post by Mark » Wed Mar 19, 2014 10:55 pm

Hi,

Use AppleScript for this:

Code: Select all

tell application "Automator Launcher"
   open "/path/to/file.workflow"
end tell
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Running an Automator file

Post by Mag » Wed Mar 19, 2014 11:33 pm

Thank you Mike!

You won two more questions, test your knowledge... :P

1. And to run an applescript file?
2. Is there differences by run an external AS file and run a AS script from a contained with the command Do as applescript? (I know this one it's a bit naif)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Running an Automator file

Post by Mark » Wed Mar 19, 2014 11:51 pm

Hi,

My name is not Mike. Unfortunately, I don't know your name, that's why I don't include it in the salutation.

You don't need to run an AppleScript file. Just paste the script in a field or store it in a custom property and execute it with

Code: Select all

do fld "AppleScript" as AppleScript
or

Code: Select all

do the cAppleScript of me as AppleScript
If you really want to execute a file, there are a few options. You can save the AppleScript file as an app and launch the app from within LiveCode with the launch command. You can also save the file as a script and run the syntax

Code: Select all

put "/path/to/file.scpt" into myPath
put "set myScript to (POSIX file" && quote & myPath & quote && ") as alias" & cr & \
  "run script myScript" into myAppleScript
  do myAppleScript as AppleScript
Unfortunately, you still need to store a script in a field or customer property this way. An advantage, however, might be that you don't need to store the script each time when you change it.

You can also use the shell to execute the script:

Code: Select all

put "/path/to/file.scpt" into myPath
put "osascript -e" && quote & myPath & quote into myShell
get shell(myShell)
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Running an Automator file

Post by Mag » Thu Mar 20, 2014 9:49 am

Hi Mark, sorry for the typo, I think an auto-correction issue. I know your name and also I own your book on LiveCode :oops:

Thank you so much for your post very comprehensive (as usual). I think I will go with the way to save the file as a script and run the first syntax you suggested. :D

I know there are thee formats for an applescript file, if somebody know more, please post here, thank you.
.applescript
.scpt
.scptd

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Running an Automator file

Post by Mag » Thu Mar 20, 2014 6:30 pm

Mark wrote:Hi,

Use AppleScript for this:

Code: Select all

tell application "Automator Launcher"
   open "/path/to/file.workflow"
end tell
Kind regards,

Mark

There must be something that I'm wrong... :oops:

Code: Select all

tell application "Automator Launcher"
	open "/Users/fire/Desktop/OpenPreferences.workflow"
end tell
Attachments
err.png

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Running an Automator file

Post by Mark » Thu Mar 20, 2014 6:34 pm

Hi Mag,

That surprised me. However, you can make an Automator app with exactly the same steps as a workflow. Just choose Application instead of Workflow when the dialog appears. Save the "flow" as application and just start the app like a normal app (launch "/path/to/new_application.app"). Does that work for you?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Running an Automator file

Post by Mag » Fri Mar 21, 2014 9:46 am

I Mark, maybe it's a new security limitation of Mavericks. Thank you for the workaround, This is a much less versatile solution so I will evaluate whether to include it or not.

Post Reply