messages to itunes from max with applescript and the shell object

Jan 22, 2006 at 10:21am

messages to itunes from max with applescript and the shell object

Hi everybody,

As it took me a lot of time to find how to send valid messages from
max to itunes via applescript and the shell, i want to share the
result of my work. Unfortunately, i can’t send messages to an app
whose name contains more than one word like “DVD Player”. I would be
interested if someone can tell me how to do it.

Thanks.
Philippe OLLIVIER.

————————————-
http://www.philippeollivier.com
http://www.bugelkoar.com
http://www.logellou.com

max v2;
#N vpatcher 365 181 1142 704;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 70 431 160 196617 Shell object by Bill Orcutt;
#P window setfont “Sans Serif” 12.;
#P user com 317 457 432 196620 8;
#K set 0 18017 29556 8294 28530 30561 29284 11822 11822;
#K end;
#P user com 317 400 432 196620 34;
#K set 0 21605 27756 8297 29813 28261 29472 29807 8304 27745 31008
29800 25888 28261 30836 8308 29281 25451 8289 28260 8307 25972 8308
26725 8310 28524 30061 25888 27749 30309 27680 29807 8241 12336 8192;
#K end;
#P user com 317 329 393 196620 14;
#K set 0 21349 29728 29800 25888 17745 8308 28448 10095 28199 8289
28260 8231 28518 26151;
#K end;
#P user com 317 278 393 196620 17;
#K set 0 29797 27756 8297 29813 28261 29472 29807 8304 27745 31008
29800 25888 28261 30836 8308 29281 25451;
#K end;
#P user com 317 236 393 196620 16;
#K set 0 29797 27756 8297 29813 28261 29472 29807 8304 27745 31008
24864 29541 27749 25460 26991 28160;
#K end;
#P user com 317 196 393 196620 9;
#K set 0 17263 28005 8290 24931 27424 29807 8282 25970 28416;
#K end;
#P user com 317 145 393 196620 10;
#K set 0 21615 26471 27749 8304 27745 31008 11552 28769 30067 25856;
#K end;
#P user com 317 89 393 196620 30;
#K set 0 20336 25966 8289 8308 29281 25451 8297 28192 26996 30062
25971 8300 26978 29281 29305 8311 26735 29541 8302 24941 25888 25455
28276 24937 28275 8226 21089 30305 27938 11776;
#K end;
#P window setfont “Sans Serif” 9.;
#P user com 7 241 179 196617 12;
#K set 0 21349 29728 29800 25888 30319 27765 28005 8303 26144 26996
30062 25971;
#K end;
#P user com 7 161 179 196617 13;
#K set 0 28528 25966 8289 28260 8291 27759 29541 8308 26725 8297
29813 28261 29440;
#K end;
#P window linecount 2;
#P message 317 111 374 196617 osascript -e ‘tell application
“iTunes”‘ -e ‘set mytrack to (first track of view of front window
whose (name contains “Ravam”))’ -e ‘play mytrack’ -e ‘end tell’;
#B color 6;
#P window linecount 1;
#P message 317 478 317 196617 osascript -e ‘tell application
“iTunes”‘ -e ‘fast forward’ -e ‘end tell’;
#B color 5;
#P message 317 255 257 196617 osascript -e ‘tell application “itunes”
to play selection’;
#B color 6;
#P message 317 218 316 196617 osascript -e ‘tell application “itunes”
to set the player position to 0′;
#B color 2;
#P window linecount 2;
#P message 317 421 264 196617 osascript -e ‘tell application “itunes”
to play next track’ -e ‘tell application “iTunes” to set sound volume
to 100′;
#B color 6;
#P window linecount 1;
#P message 317 368 298 196617 osascript -e ‘tell application “iTunes”
to set EQ enabled to false’;
#B color 1;
#P message 317 302 264 196617 osascript -e ‘tell application “itunes”
to play next track’;
#B color 6;
#P message 7 256 307 196617 osascript -e ‘tell application “iTunes”
to set sound volume to 100′;
#B color 6;
#P number 7 274 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 7 292 301 196617 osascript -e ‘tell application “iTunes”
to set sound volume to $1′;
#B color 6;
#P message 317 166 241 196617 osascript -e ‘tell application “iTunes”
to playpause’;
#B color 14;
#P message 7 177 217 196617 osascript -e ‘tell application “iTunes”
to open’;
#B color 14;
#P message 317 349 295 196617 osascript -e ‘tell application “iTunes”
to set EQ enabled to true’;
#B color 1;
#P message 7 136 216 196617 osascript -e ‘tell application “Finder”
to open’;
#B color 5;
#P message 7 118 213 196617 osascript -e ‘tell application “Finder”
to quit’;
#B color 5;
#P message 7 194 214 196617 osascript -e ‘tell application “iTunes”
to quit’;
#B color 14;
#P newex 126 401 30 196617 shell;
#P user com 7 97 179 196617 13;
#K set 0 28528 25966 8289 28260 8291 27759 29541 8308 26725 8294
26990 25701 29184;
#K end;
#P window setfont “Sans Serif” 18.;
#P window linecount 2;
#P comment 4 23 367 196626 Here is an example to send applescript
commands to itunes via the shell object;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 70 445 160 196617 http://www.publicbeta.cx/max/;
#P connect 11 0 10 0;
#P connect 18 0 3 0;
#P connect 17 0 3 0;
#P connect 16 0 3 0;
#P connect 15 0 3 0;
#P connect 8 0 3 0;
#P connect 14 0 3 0;
#P connect 13 0 3 0;
#P connect 12 0 3 0;
#P connect 10 0 3 0;
#P connect 7 0 3 0;
#P connect 9 0 3 0;
#P connect 6 0 3 0;
#P connect 5 0 3 0;
#P connect 4 0 3 0;
#P connect 19 0 3 0;
#P pop;

#24032
Jan 22, 2006 at 11:12am

You could rename “DVD player” to “DVD_Player”

Best,
Jakob

#68900
Jan 22, 2006 at 12:11pm

On 22-janv.-06, at 12:12, Jakob Riis wrote:

> You could rename “DVD player” to “DVD_Player”

I’m afraid this should be avoided… This solution makes your patch not
portable, and I don’t know how OSX will be able to update DVD Player.


I recently didn’t understand why, in reaktor’s contextual menus, I
couldn’t find some items (empty macro for instance) I found on other
machines until I understood it was because I changed Reaktor’s folder
name from “Reaktor5″ to “Reaktor5.1″.
Obvious pathes issues, as you could also encounter with Max, btw.

Using a backslash before the space works.

-> osascript -e ‘tell application “DVDPlayer player” to open’

p

#68901
Jan 22, 2006 at 2:23pm

This is very interesting. I see that you can open the system preferences this way. Now what i’d like to know is how does one go about finding the right scripts to open (for example) the energy saver panel and set the processor to high performance – that would be quite handy…

best,

john.

#68902
Jan 22, 2006 at 2:34pm

As i was searching for info on scripting i found Doug’s AppleScripts for iTunes which might be handy for some…

http://www.dougscripts.com/itunes/

j

#68903
Jan 22, 2006 at 8:06pm

Thanks for your work. It seems to work nicely!

#68904
Jan 22, 2006 at 9:47pm

Check into system events apple scripting. None of the preference
panes are currently very scriptable, so the system events library
lets you simulate actually clicking on tabs and buttons, entering
text into text fields, etc.
That’s probably your best bet.

Honestly, I’d assume there is a way to access this functionality
through the more robust “defaults” tool (the supported way of
affecting preferences via the shell).
man defaults for more info.

_Mark

#68905
Jan 22, 2006 at 11:52pm

Quote: Mark Pauley wrote on Sun, 22 January 2006 14:47
—————————————————-
> Honestly, I’d assume there is a way to access this functionality
> through the more robust “defaults” tool (the supported way of
> affecting preferences via the shell).
> man defaults for more info.

thanks for that, pretty cool…

this is a bit of pain (though perfectly logical)

[i]Note: Since applications do access the defaults system while they’re run-
ning, you shouldn’t modify the defaults of a running application. If you
change a default in a domain that belongs to a running application, the
application won’t see the change and might even overwrite the default.[/i]

#68906

You must be logged in to reply to this topic.