MonoMac - how can I execute apple script

I am trying to create a simple application with MonoMac and have to run an apple script to access playlist information from different media players (see my previous question ).

I decided to try MonoMac because I am very familiar with the development of C # and .net, and there is a good implementation of Websocket.

Unfortunately, for NSAppleScript, there seems to be no working shell. I tried Deploying Frederic Forjans and tried using monobjc .

The Frederick shell class doesn't even compile when I use its code. I get the following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'MonoMac, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies.
File name: 'MonoMac, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null'

when creating a new instance NSString. However new NSDictionary();, which is in the same assembly, works great.

When using monobjc I get the following error:

Unhandled Exception: System.TypeInitializationException: An exception was 
thrown by the type initializer for Monobjc.ObjectiveCRuntime ---> 
System.EntryPointNotFoundException: monobjc_install_bridge
  at (wrapper managed-to-native) Monobjc.NativeMethods: InstallBridge ()
  at Monobjc.ObjectiveCRuntime..cctor () [0x00000] in: 0 
  --- End of inner exception stack trace ---
  at CocoaApplication1.Program.Main () [0x00000] in: 0 

Can anyone suggest a simple and efficient way to execute Apple scripts in a mono environment?

+3
source share
3 answers

You cannot use Monobjc assemblies directly without running them with the binary version of Monobjc. If you want to create a Cocoa-based application or a console application, there are tutorials for this on the Monobjc website to help you get started.

The easiest way to achieve interoperability between applications is to use the ScriptingBridge framework. Many applications provide script definitions that can then be used in an object-oriented manner: more about this guide .

, (, iTunes, iCal, iMovie, Finder ..).

Monobjc ScriptingBridge; (SBSetFinderComment ScriptingBridgeiCal), , .

+4

, Monobjc. Monobjc AppleScript.

:

string script = ". . . . . . . . . ."; // some applescript text
NSDictionary error = null;
NSAppleScript scr = new NSAppleScript(script);
NSAppleEventDescriptor result = scr.ExecuteAndReturnError(out error);
string retval = result.StringValue;

, . Monobjc.

+1

AppleScript WinForms Mono AppleScript AppleScript Slim.! 00% Mono Develop.

AppleScript Slim: https://applescriptslim.codeplex.com/

0

All Articles