Forums > MaxMSP

how to run an applescript with "shell" object?

July 12, 2008 | 11:32 pm

can anyone tell me how?

thank you so from madrid!!

July 13, 2008 | 8:35 am

July 13, 2008 | 11:15 am

hello, I try but nothing happenps!,

I just want to display an screen message when I do some tasks with max

something like this:

tell application "MaxMSP"
tell application "AirClick"
simulate virtual key code 17
display message "Button 1"
tell application "TextEdit"
end tell
end tell
end tell

how could I do it?


July 13, 2008 | 11:40 am

Try typing ‘man osascript’ in the terminal to see what arguments
osascript needs.

July 13, 2008 | 12:06 pm

hello, this is the simple script I need to run… and it

July 13, 2008 | 1:40 pm

did you try to paste that line directly in the terminal? Was there any
error message, or any kind of feedback?
you can also write a script to a file, and let osascript use it(also
try with the terminal first, then with max).

I can’t fully test this out since I don’t have the "SEC Helper" app,
but I suspect that the character ` before the word "using" could be a
problem here.

On Jul 13, 2008, at 2:06 PM, gamuso wrote:


July 13, 2008 | 2:36 pm

hello, thanks for helping…

but I

July 13, 2008 | 4:18 pm

try this: save script as "mybestscriptever.scpt" in the same folder
where your patch is saved, and then call it with:

osascript mybestscriptever.scpt

or if you’re using the -e approach, you’re probably entering the world
of symbolic pain. simple example would be message box with the:

osascript -e’tell application "Finder"‘ -e activate -e end tell


it’s really very very simple: just study carefully the way max handles
symbols, osascript manual, actionscript, shell(s), google for error
messages, search max forum and eventually you’ll figure it out.

July 13, 2008 | 8:16 pm

well, since I wrote ‘actionscript’ instead of applescript(and because
information about escapes and symbols is dispersed throughout the
docs&forum), I’ll give you a hint:

whole osascript line should be one symbol, meaning you should put all
of it in quotes.

but since there are already quotes in your call ("SEC Helper"), and
they have special meaning in max, you’ll have to escape them with ,
meaning: insert before " to get ", but not before first and last
double quotes(which define max symbol).

I’ve just installed sec helper thing, typed correctly formated
message, and it worked, so you know now it’s possible.

If this is too urgent for you, and you don’t want to know at this
point how symbols in max work, look here what to type into the message
box to make it work:

July 13, 2008 | 9:13 pm

July 14, 2008 | 2:59 pm

ey, thanks to you all,

this info is helpfull for me!

thankyou so

July 15, 2008 | 5:34 pm

my applescript is:

tell application "Live"

tell application "System Events"
key down command
keystroke "w"
key up command
keystroke "d"
end tell
end tell

tell application "Live"

set new_file to "Macintosh HD:Users:andrewrobertson:Work:Live:MyLiveSets:B-Keeper2008:B-KeeperTemplate2.als"
open file new_file
end tell

this works fine in script editor

however, when I start trying things like:

osascript -e ‘tell application "live" ‘ -e ‘activate’ -e ‘end tell’ -e ‘tell application "System Events"‘ -e ‘key down command’ -e ‘keystroke /"w/"‘ -e ‘key up command’ -e ‘keystroke /"d/"‘ -e ‘end tell’

with shell, it doesn;t work.

What’s the method with scpt – I haven’t got that working yet, and how do you deal with enter and apostrophes etc..?

Can anyone give a very clear answer for a simple script that will work whilst also using more than one line?


July 15, 2008 | 5:57 pm


Okay…so within minutes I’m answering my own question (well, with some help from Enrique, talented colleague..) – maybe I should have tried this before ..but this may help others too

[osascript users/andrewrobertson/Work/MadMax/MaxPatches/Refresh.scpt]

[ ] is the message box

into shell runs the script

open users/andrewrobertson/Work/MadMax/MaxPatches/Refresh.scpt

will open it.

I think I made a slip-up with a dash or something.
Easiest way to check – put it right back at the root and move up from there…

This would seem a much better way to run applescript than the -e ‘ /" etc

Viewing 13 posts - 1 through 13 (of 13 total)

Forums > MaxMSP