AppleScript Slim is a library containing the portions of Mono required to run AppleScripts and pretty much nothing else. This allows you to take a standard .NET application, in my case a WinForms application, and add AppleScript support to it. Of course AppleScript will only work when running on a Mac, so make sure to do an OS check.

Here is a code sample showing changing the desktop wallpaper using AppleScript which is then executed using the library:

           string applScript =
@"set theUnixPath to POSIX file ""{0}"" as text 
tell application ""Finder"" 
set desktop picture to {{theUnixPath}} as alias 
end tell";

            MonoDevelop.MacInterop.AppleScript.Run(string.Format(applScript, localPath));


Full credit for the code used goes to the great people at Mono Develop (http://monodevelop.com/). None of this code was written by me, I just pruned and packaged it.

Last edited Jun 2, 2012 at 3:58 PM by patricker, version 3