Max/MSP Quick Tip #5: Applescript in Max
Often when working on a project that needs to interact with other apps on the system it is useful to know some Applescript. Applescript is Apple’s own consumer level programming/scripting language that allows users to customise their computers or streamline certain repetitive tasks. As Max has the ability to run Applescripts using the Shell external we can control and automate certain functions outside of Max fair easily.
* I’ve purposely not dealt with particular script examples here because the possibilities are endless and a simple Google search will usually suffice for most purposes, along with Apple’s own help files.
Scripts are written in the Applescript Editor that ships with all macs and then triggered from within max with a message box attached to the shell object, like so:
Equally scripts can also be written in Max and triggered in a similar way however due to the way Max formats things it’s sometimes more complex working in this way, especially if the script is longer than one line.
This script, as you can probably tell, will close the first tab you have open in Google’s Chrome browser. (Notice in this example the quotation marks need to be escaped with a backslash which is due to Max and is not anything to do with Applescript itself).
Hopefully this post is helpful for those struggling to get the correct syntax when working with Applescript specifically in Max, something i struggled with a lot in the beginning due to the lack of concise information on the C74 forums.