Forums > MaxMSP

OSX Standalone File association

January 14, 2008 | 7:20 am

Hi,

I have made a standalone which uses pattr xml files to store setups. I would like to associate xml files written with my standalone to my app, so that when they are double clicked in the os my app is launched (also they should have their own icon). Can any osx gurus tell me the steps needed to do this or if it is possible? I guess I have to edit the plist.

cheers,

oli


January 14, 2008 | 8:40 am

hi oli,

this is something i gleaned from michael egger’s LiveCut app.

use the SetFile *nix tool through shell to assign the file your
filetype and creator-code

copy the unix binary into the app bundle to be sure it’s available. on
my machine it’s located in /usr/bin/ and is universal.

then run the following shell command to assign for example the
filetype svg and the creator adobe illustrator

"/path/to/SetFile" -t svg -c ART5 "/path/to/file/Untitled.svg";

jeremy bernstein has an external called filetype that also has these
funcionalities http://www.cycling74.com/twiki/pub/Share/JeremyBernstein/filetypeUB.zip

hth

/*j

btw: i like your intlib interpolations!

#P inlet 89 39 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P message 201 297 251 196617 "/path/to/SetFile" -t svg -c ART5 "/path/
to/Untitled.svg";
#P window linecount 1;
#P newex 188 297 14 196617 _;
#P button 89 70 15 0;
#P newex 89 122 100 196617 v path_app_binaries;
#P newex 328 145 81 196617 v xml_file_path;
#P newex 89 242 228 196617 sprintf \\"%s\\" -t "svg " -c ART5 \
"%s\\";
#N vpatcher 109 497 509 797;
#P outlet 138 180 15 0;
#P inlet 138 22 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 151 80 50 196617 strrchr :;
#P newex 138 126 42 196617 strrcut;
#P connect 2 0 0 0;
#P fasten 1 0 0 0 156 114 143 114;
#P connect 0 0 3 0;
#P fasten 2 0 1 0 143 58 156 58;
#P pop;
#P newobj 328 198 85 196617 p strip_rootname;
#N vpatcher 109 497 509 797;
#P outlet 138 180 15 0;
#P inlet 138 22 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 151 80 50 196617 strrchr :;
#P newex 138 126 42 196617 strrcut;
#P connect 2 0 0 0;
#P fasten 1 0 0 0 156 114 143 114;
#P connect 0 0 3 0;
#P fasten 2 0 1 0 143 58 156 58;
#P pop;
#P newobj 89 204 85 196617 p strip_rootname;
#P newex 89 166 234 196617 sprintf %sMyAPP.app/Contents/MacOS/SetFile;
#P newex 89 278 81 196617 shell;
#P connect 10 0 7 0;
#P connect 2 0 4 0;
#P connect 8 0 9 0;
#P fasten 3 0 4 1 333 226 312 226;
#P connect 7 0 5 0;
#P connect 7 0 6 0;
#P connect 5 0 3 0;
#P connect 4 0 8 0;
#P connect 4 0 0 0;
#P connect 1 0 2 0;
#P connect 6 0 1 0;
#P window clipboard copycount 11;


January 15, 2008 | 8:50 am

Thanks!

Now if only i could stop the xml file opening in max’s texteditor…

oli


January 15, 2008 | 9:08 am

On 15 janv. 08, at 09:50, Oliver Larkin wrote:

> Thanks!
>
> Now if only i could stop the xml file opening in max’s texteditor…

I did an ugly hack once (well… maybe twice;)) for an application: I
was closing the window via applescript (shell + osascript /
tap.applescript). Not very elegant, but at least the window disappeared.

ej


January 16, 2008 | 8:48 am

hi ej,

I’m trying to use an applescript but can’t seem to get anything to happen. Here’s my script…

osascript -e ‘tell application |MaxMSP| to close every window whose name is |hello.txt|’

I turned on "enable access to assistive devices". Do you have any ideas what is wrong with my script?

thanks,

Oli


January 16, 2008 | 10:40 am

Emmanuel Jourdan schrieb:
> I did an ugly hack once (well… maybe twice;)) for an application: I
> was closing the window via applescript (shell + osascript /
> tap.applescript). Not very elegant, but at least the window disappeared.

This could be a feature request for Max 5.1 if it isn’t addressed
already: Have a standalone react on opening with certain file types in a
consistent way…
I guess this would turn Max much more into a general purpose developing
platform than it is now…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


January 16, 2008 | 12:03 pm

On 16 janv. 08, at 09:48, Oliver Larkin wrote:

> I’m trying to use an applescript but can’t seem to get anything to
> happen. Here’s my script…
>
> osascript -e ‘tell application |MaxMSP| to close every window whose
> name is |hello.txt|’
>
> I turned on "enable access to assistive devices". Do you have any
> ideas what is wrong with my script?

I couldn’t make this work either. I did that by using System Events
that way to emulate keyboard shortcuts:

tell application "YourMaxApp"
activate
tell application "System Events"
keystroke "< " using command down
keystroke "W" using command down
end tell
end tell

Which makes that it use the command+< keyboard shortcut to switch to
the next window, and command+w to close it.

ej


January 16, 2008 | 12:18 pm

thanks, that’s great! I needed to change the capital W to lower case e.g.

tell application "YourApp"
activate
tell application "System Events"
keystroke "< " using command down
keystroke "w" using command down
end tell
end tell


January 16, 2008 | 3:03 pm

On 16 janv. 08, at 11:40, Stefan Tiedje wrote:

> Emmanuel Jourdan schrieb:
>> I did an ugly hack once (well… maybe twice;)) for an application:
>> I was closing the window via applescript (shell + osascript /
>> tap.applescript). Not very elegant, but at least the window
>> disappeared.
>
> This could be a feature request for Max 5.1 if it isn’t addressed
> already: Have a standalone react on opening with certain file types
> in a consistent way…
> I guess this would turn Max much more into a general purpose
> developing platform than it is now…

Request registered, no promise though.

ej


January 16, 2008 | 8:00 pm

While your at it…Any chance we can have full control over the standalone menu bar in Max 5 too?

cheers,

oli


January 16, 2008 | 9:54 pm

I modified some code from Philippe Gruchet so that the window of the text file that is opened is closed. Not sure if that is safer or not.

#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P newex 66 116 288 196617 sprintf osascript -e ‘tell application |System Events|’ -e ‘click button 3 of window |%s| of process |MaxMSP|’ -e ‘end tell’;
#P window linecount 1;
#P newex 51 63 40 196617 opened;
#P newex 66 195 19 196617 34;
#P newex 66 176 45 196617 sel 124;
#P newex 66 245 44 196617 itoa;
#P newex 66 226 45 196617 thresh;
#P newex 66 157 45 196617 spell;
#P newex 66 264 45 196617 shell;
#P connect 3 0 0 0;
#P connect 2 0 3 0;
#P connect 5 0 2 0;
#P connect 4 1 2 0;
#P connect 4 0 5 0;
#P connect 1 0 4 0;
#P connect 7 0 1 0;
#P connect 6 1 7 0;
#P window clipboard copycount 8;


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